webview not loading correctly in application









up vote
0
down vote

favorite












I have an application that has a tab widget in it. One of the tabs loads a webview for me and it is not loading correctly. when i load the same address in just my phone browser it loads fine. here is the code for the webview i'm using



import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class Sermons extends Activity
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
WebView webview = new WebView(this);
setContentView(webview);

// Simplest usage: note that an exception will NOT be thrown
// if there is an error loading this page (see below).
webview.loadUrl("http://canyonculberts.com/ucc/?page_id=93");
webview.getSettings().setBuiltInZoomControls(true);
webview.setInitialScale(1);
webview.getSettings().setAppCacheEnabled(false);





anyone have any thoughts on what i can do different on this to make it work correctly? Thank you for any help










share|improve this question

























    up vote
    0
    down vote

    favorite












    I have an application that has a tab widget in it. One of the tabs loads a webview for me and it is not loading correctly. when i load the same address in just my phone browser it loads fine. here is the code for the webview i'm using



    import android.app.Activity;
    import android.os.Bundle;
    import android.webkit.WebView;

    public class Sermons extends Activity
    public void onCreate(Bundle savedInstanceState)
    super.onCreate(savedInstanceState);
    WebView webview = new WebView(this);
    setContentView(webview);

    // Simplest usage: note that an exception will NOT be thrown
    // if there is an error loading this page (see below).
    webview.loadUrl("http://canyonculberts.com/ucc/?page_id=93");
    webview.getSettings().setBuiltInZoomControls(true);
    webview.setInitialScale(1);
    webview.getSettings().setAppCacheEnabled(false);





    anyone have any thoughts on what i can do different on this to make it work correctly? Thank you for any help










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have an application that has a tab widget in it. One of the tabs loads a webview for me and it is not loading correctly. when i load the same address in just my phone browser it loads fine. here is the code for the webview i'm using



      import android.app.Activity;
      import android.os.Bundle;
      import android.webkit.WebView;

      public class Sermons extends Activity
      public void onCreate(Bundle savedInstanceState)
      super.onCreate(savedInstanceState);
      WebView webview = new WebView(this);
      setContentView(webview);

      // Simplest usage: note that an exception will NOT be thrown
      // if there is an error loading this page (see below).
      webview.loadUrl("http://canyonculberts.com/ucc/?page_id=93");
      webview.getSettings().setBuiltInZoomControls(true);
      webview.setInitialScale(1);
      webview.getSettings().setAppCacheEnabled(false);





      anyone have any thoughts on what i can do different on this to make it work correctly? Thank you for any help










      share|improve this question













      I have an application that has a tab widget in it. One of the tabs loads a webview for me and it is not loading correctly. when i load the same address in just my phone browser it loads fine. here is the code for the webview i'm using



      import android.app.Activity;
      import android.os.Bundle;
      import android.webkit.WebView;

      public class Sermons extends Activity
      public void onCreate(Bundle savedInstanceState)
      super.onCreate(savedInstanceState);
      WebView webview = new WebView(this);
      setContentView(webview);

      // Simplest usage: note that an exception will NOT be thrown
      // if there is an error loading this page (see below).
      webview.loadUrl("http://canyonculberts.com/ucc/?page_id=93");
      webview.getSettings().setBuiltInZoomControls(true);
      webview.setInitialScale(1);
      webview.getSettings().setAppCacheEnabled(false);





      anyone have any thoughts on what i can do different on this to make it work correctly? Thank you for any help







      android webview






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 24 '12 at 4:02









      Bryan

      1701722




      1701722






















          4 Answers
          4






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          First, you need android.permission.INTERNET permission.



          Second, you may need setJavaScriptEnabled(true) to settings, and do loadUrl at the very last.



          webview.getSettings().setBuiltInZoomControls(true);
          webview.setInitialScale(1);
          webview.getSettings().setAppCacheEnabled(false);
          webview.getSettings().setJavaScriptEnabled(true);
          webview.loadUrl("http://canyonculberts.com/ucc/?page_id=93");





          share|improve this answer


















          • 1




            ok i have internet permission done already, where do i do the setJavaScriptEnable at is it in the code i have here or where?
            – Bryan
            Feb 24 '12 at 4:17










          • check the update.
            – Cytown
            Feb 24 '12 at 11:27







          • 1




            WOW that worked great and worked perfectly THANK YOU FOR THAT VERY MUCH
            – Bryan
            Feb 26 '12 at 0:58

















          up vote
          1
          down vote













          You have to try this code It wiil help you!



           WebView webview = new WebView(this);
          setContentView(webview);

          WebSettings webSettings = web.getSettings();

          webSettings.setJavaScriptEnabled(true);

          webview.loadUrl("url");





          share|improve this answer






















          • gives me an error on the (R.id.web) any suggestions. it says web cannot be resolved
            – Bryan
            Feb 24 '12 at 4:21










          • @Bryan see edited answer first. I think its solve there was variable problem
            – Newts
            Feb 24 '12 at 4:27











          • It will helpful to you!
            – Newts
            Feb 24 '12 at 4:45










          • I think we are on the right path but now my app is force closing on launch and this is all i've changed, any ideas why
            – Bryan
            Feb 24 '12 at 4:54










          • what is your logcat error
            – Newts
            Feb 24 '12 at 4:57

















          up vote
          0
          down vote













          Try with this..



           webView = (WebView) findViewById(R.id.webview);
          webView.getSettings().setJavaScriptEnabled(true);
          webView.setWebViewClient(new WebViewClient());
          webView.loadUrl("http://www.google.com");





          share|improve this answer




















          • get unresolved error with the (R.id.webview) with this code as well
            – Bryan
            Feb 24 '12 at 5:03






          • 1




            R u added the webview widget in ur xml file.
            – user1213202
            Feb 24 '12 at 5:41

















          up vote
          0
          down vote













          Actually, After I tried many times .. I Solved it by adding this line.



          mWebView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Mobile Safari/537.36");





          share|improve this answer




















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9425212%2fwebview-not-loading-correctly-in-application%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            4 Answers
            4






            active

            oldest

            votes








            4 Answers
            4






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote



            accepted










            First, you need android.permission.INTERNET permission.



            Second, you may need setJavaScriptEnabled(true) to settings, and do loadUrl at the very last.



            webview.getSettings().setBuiltInZoomControls(true);
            webview.setInitialScale(1);
            webview.getSettings().setAppCacheEnabled(false);
            webview.getSettings().setJavaScriptEnabled(true);
            webview.loadUrl("http://canyonculberts.com/ucc/?page_id=93");





            share|improve this answer


















            • 1




              ok i have internet permission done already, where do i do the setJavaScriptEnable at is it in the code i have here or where?
              – Bryan
              Feb 24 '12 at 4:17










            • check the update.
              – Cytown
              Feb 24 '12 at 11:27







            • 1




              WOW that worked great and worked perfectly THANK YOU FOR THAT VERY MUCH
              – Bryan
              Feb 26 '12 at 0:58














            up vote
            1
            down vote



            accepted










            First, you need android.permission.INTERNET permission.



            Second, you may need setJavaScriptEnabled(true) to settings, and do loadUrl at the very last.



            webview.getSettings().setBuiltInZoomControls(true);
            webview.setInitialScale(1);
            webview.getSettings().setAppCacheEnabled(false);
            webview.getSettings().setJavaScriptEnabled(true);
            webview.loadUrl("http://canyonculberts.com/ucc/?page_id=93");





            share|improve this answer


















            • 1




              ok i have internet permission done already, where do i do the setJavaScriptEnable at is it in the code i have here or where?
              – Bryan
              Feb 24 '12 at 4:17










            • check the update.
              – Cytown
              Feb 24 '12 at 11:27







            • 1




              WOW that worked great and worked perfectly THANK YOU FOR THAT VERY MUCH
              – Bryan
              Feb 26 '12 at 0:58












            up vote
            1
            down vote



            accepted







            up vote
            1
            down vote



            accepted






            First, you need android.permission.INTERNET permission.



            Second, you may need setJavaScriptEnabled(true) to settings, and do loadUrl at the very last.



            webview.getSettings().setBuiltInZoomControls(true);
            webview.setInitialScale(1);
            webview.getSettings().setAppCacheEnabled(false);
            webview.getSettings().setJavaScriptEnabled(true);
            webview.loadUrl("http://canyonculberts.com/ucc/?page_id=93");





            share|improve this answer














            First, you need android.permission.INTERNET permission.



            Second, you may need setJavaScriptEnabled(true) to settings, and do loadUrl at the very last.



            webview.getSettings().setBuiltInZoomControls(true);
            webview.setInitialScale(1);
            webview.getSettings().setAppCacheEnabled(false);
            webview.getSettings().setJavaScriptEnabled(true);
            webview.loadUrl("http://canyonculberts.com/ucc/?page_id=93");






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 24 '12 at 11:28

























            answered Feb 24 '12 at 4:15









            Cytown

            1,33585




            1,33585







            • 1




              ok i have internet permission done already, where do i do the setJavaScriptEnable at is it in the code i have here or where?
              – Bryan
              Feb 24 '12 at 4:17










            • check the update.
              – Cytown
              Feb 24 '12 at 11:27







            • 1




              WOW that worked great and worked perfectly THANK YOU FOR THAT VERY MUCH
              – Bryan
              Feb 26 '12 at 0:58












            • 1




              ok i have internet permission done already, where do i do the setJavaScriptEnable at is it in the code i have here or where?
              – Bryan
              Feb 24 '12 at 4:17










            • check the update.
              – Cytown
              Feb 24 '12 at 11:27







            • 1




              WOW that worked great and worked perfectly THANK YOU FOR THAT VERY MUCH
              – Bryan
              Feb 26 '12 at 0:58







            1




            1




            ok i have internet permission done already, where do i do the setJavaScriptEnable at is it in the code i have here or where?
            – Bryan
            Feb 24 '12 at 4:17




            ok i have internet permission done already, where do i do the setJavaScriptEnable at is it in the code i have here or where?
            – Bryan
            Feb 24 '12 at 4:17












            check the update.
            – Cytown
            Feb 24 '12 at 11:27





            check the update.
            – Cytown
            Feb 24 '12 at 11:27





            1




            1




            WOW that worked great and worked perfectly THANK YOU FOR THAT VERY MUCH
            – Bryan
            Feb 26 '12 at 0:58




            WOW that worked great and worked perfectly THANK YOU FOR THAT VERY MUCH
            – Bryan
            Feb 26 '12 at 0:58












            up vote
            1
            down vote













            You have to try this code It wiil help you!



             WebView webview = new WebView(this);
            setContentView(webview);

            WebSettings webSettings = web.getSettings();

            webSettings.setJavaScriptEnabled(true);

            webview.loadUrl("url");





            share|improve this answer






















            • gives me an error on the (R.id.web) any suggestions. it says web cannot be resolved
              – Bryan
              Feb 24 '12 at 4:21










            • @Bryan see edited answer first. I think its solve there was variable problem
              – Newts
              Feb 24 '12 at 4:27











            • It will helpful to you!
              – Newts
              Feb 24 '12 at 4:45










            • I think we are on the right path but now my app is force closing on launch and this is all i've changed, any ideas why
              – Bryan
              Feb 24 '12 at 4:54










            • what is your logcat error
              – Newts
              Feb 24 '12 at 4:57














            up vote
            1
            down vote













            You have to try this code It wiil help you!



             WebView webview = new WebView(this);
            setContentView(webview);

            WebSettings webSettings = web.getSettings();

            webSettings.setJavaScriptEnabled(true);

            webview.loadUrl("url");





            share|improve this answer






















            • gives me an error on the (R.id.web) any suggestions. it says web cannot be resolved
              – Bryan
              Feb 24 '12 at 4:21










            • @Bryan see edited answer first. I think its solve there was variable problem
              – Newts
              Feb 24 '12 at 4:27











            • It will helpful to you!
              – Newts
              Feb 24 '12 at 4:45










            • I think we are on the right path but now my app is force closing on launch and this is all i've changed, any ideas why
              – Bryan
              Feb 24 '12 at 4:54










            • what is your logcat error
              – Newts
              Feb 24 '12 at 4:57












            up vote
            1
            down vote










            up vote
            1
            down vote









            You have to try this code It wiil help you!



             WebView webview = new WebView(this);
            setContentView(webview);

            WebSettings webSettings = web.getSettings();

            webSettings.setJavaScriptEnabled(true);

            webview.loadUrl("url");





            share|improve this answer














            You have to try this code It wiil help you!



             WebView webview = new WebView(this);
            setContentView(webview);

            WebSettings webSettings = web.getSettings();

            webSettings.setJavaScriptEnabled(true);

            webview.loadUrl("url");






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 24 '12 at 4:26

























            answered Feb 24 '12 at 4:17









            Newts

            1,3731121




            1,3731121











            • gives me an error on the (R.id.web) any suggestions. it says web cannot be resolved
              – Bryan
              Feb 24 '12 at 4:21










            • @Bryan see edited answer first. I think its solve there was variable problem
              – Newts
              Feb 24 '12 at 4:27











            • It will helpful to you!
              – Newts
              Feb 24 '12 at 4:45










            • I think we are on the right path but now my app is force closing on launch and this is all i've changed, any ideas why
              – Bryan
              Feb 24 '12 at 4:54










            • what is your logcat error
              – Newts
              Feb 24 '12 at 4:57
















            • gives me an error on the (R.id.web) any suggestions. it says web cannot be resolved
              – Bryan
              Feb 24 '12 at 4:21










            • @Bryan see edited answer first. I think its solve there was variable problem
              – Newts
              Feb 24 '12 at 4:27











            • It will helpful to you!
              – Newts
              Feb 24 '12 at 4:45










            • I think we are on the right path but now my app is force closing on launch and this is all i've changed, any ideas why
              – Bryan
              Feb 24 '12 at 4:54










            • what is your logcat error
              – Newts
              Feb 24 '12 at 4:57















            gives me an error on the (R.id.web) any suggestions. it says web cannot be resolved
            – Bryan
            Feb 24 '12 at 4:21




            gives me an error on the (R.id.web) any suggestions. it says web cannot be resolved
            – Bryan
            Feb 24 '12 at 4:21












            @Bryan see edited answer first. I think its solve there was variable problem
            – Newts
            Feb 24 '12 at 4:27





            @Bryan see edited answer first. I think its solve there was variable problem
            – Newts
            Feb 24 '12 at 4:27













            It will helpful to you!
            – Newts
            Feb 24 '12 at 4:45




            It will helpful to you!
            – Newts
            Feb 24 '12 at 4:45












            I think we are on the right path but now my app is force closing on launch and this is all i've changed, any ideas why
            – Bryan
            Feb 24 '12 at 4:54




            I think we are on the right path but now my app is force closing on launch and this is all i've changed, any ideas why
            – Bryan
            Feb 24 '12 at 4:54












            what is your logcat error
            – Newts
            Feb 24 '12 at 4:57




            what is your logcat error
            – Newts
            Feb 24 '12 at 4:57










            up vote
            0
            down vote













            Try with this..



             webView = (WebView) findViewById(R.id.webview);
            webView.getSettings().setJavaScriptEnabled(true);
            webView.setWebViewClient(new WebViewClient());
            webView.loadUrl("http://www.google.com");





            share|improve this answer




















            • get unresolved error with the (R.id.webview) with this code as well
              – Bryan
              Feb 24 '12 at 5:03






            • 1




              R u added the webview widget in ur xml file.
              – user1213202
              Feb 24 '12 at 5:41














            up vote
            0
            down vote













            Try with this..



             webView = (WebView) findViewById(R.id.webview);
            webView.getSettings().setJavaScriptEnabled(true);
            webView.setWebViewClient(new WebViewClient());
            webView.loadUrl("http://www.google.com");





            share|improve this answer




















            • get unresolved error with the (R.id.webview) with this code as well
              – Bryan
              Feb 24 '12 at 5:03






            • 1




              R u added the webview widget in ur xml file.
              – user1213202
              Feb 24 '12 at 5:41












            up vote
            0
            down vote










            up vote
            0
            down vote









            Try with this..



             webView = (WebView) findViewById(R.id.webview);
            webView.getSettings().setJavaScriptEnabled(true);
            webView.setWebViewClient(new WebViewClient());
            webView.loadUrl("http://www.google.com");





            share|improve this answer












            Try with this..



             webView = (WebView) findViewById(R.id.webview);
            webView.getSettings().setJavaScriptEnabled(true);
            webView.setWebViewClient(new WebViewClient());
            webView.loadUrl("http://www.google.com");






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Feb 24 '12 at 4:58









            user1213202

            1,2721123




            1,2721123











            • get unresolved error with the (R.id.webview) with this code as well
              – Bryan
              Feb 24 '12 at 5:03






            • 1




              R u added the webview widget in ur xml file.
              – user1213202
              Feb 24 '12 at 5:41
















            • get unresolved error with the (R.id.webview) with this code as well
              – Bryan
              Feb 24 '12 at 5:03






            • 1




              R u added the webview widget in ur xml file.
              – user1213202
              Feb 24 '12 at 5:41















            get unresolved error with the (R.id.webview) with this code as well
            – Bryan
            Feb 24 '12 at 5:03




            get unresolved error with the (R.id.webview) with this code as well
            – Bryan
            Feb 24 '12 at 5:03




            1




            1




            R u added the webview widget in ur xml file.
            – user1213202
            Feb 24 '12 at 5:41




            R u added the webview widget in ur xml file.
            – user1213202
            Feb 24 '12 at 5:41










            up vote
            0
            down vote













            Actually, After I tried many times .. I Solved it by adding this line.



            mWebView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Mobile Safari/537.36");





            share|improve this answer
























              up vote
              0
              down vote













              Actually, After I tried many times .. I Solved it by adding this line.



              mWebView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Mobile Safari/537.36");





              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                Actually, After I tried many times .. I Solved it by adding this line.



                mWebView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Mobile Safari/537.36");





                share|improve this answer












                Actually, After I tried many times .. I Solved it by adding this line.



                mWebView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Mobile Safari/537.36");






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 11 at 16:16









                7uthaifah

                618




                618



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9425212%2fwebview-not-loading-correctly-in-application%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    What does pagestruct do in Eviews?

                    Dutch intervention in Lombok and Karangasem

                    Channel Islands