Note that there are some explanatory texts on larger screens.

plurals
  1. POWebView.loadUrl() only works for every 2nd call
    primarykey
    data
    text
    <p>I have an activity containing a WebView:</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); webView = new WebView(this); setContentView(webView); webView.getSettings().setUserAgentString(MY_CLIENT); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setLoadWithOverviewMode(true); webView.getSettings().setUseWideViewPort(true); webView.setWebViewClient(new MyWebViewClient()); } </code></pre> <p>My activity defines 2 menu items, which shall result in loading of 2 different URLs URL1 and URL2:</p> <pre><code>public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_url1: webView.loadUrl(URL1); return true; case R.id.menu_url2: webView.loadUrl(URL2); return true; default: return super.onOptionsItemSelected(item); } } </code></pre> <p>However, an URL is only loaded for the 2nd time the according menu item is selected. Setting breakpoints in MyWebViewClient.onPageStarted() and MyWebViewClient.onPageFinished() shows that on the first click, onPageFinished() is called, but the url is not loaded into the WebView. On the 2nd click, onPageStarted() is invoked, followed by two invocations of onPageFinished(), and the url is loaded into the WebView. If I then try to load the other URL, the process starts over, and again two clicks are needed.</p> <p>My target Android SDK is 17, min SDK is 8. I'm testing on a Nexus 7.</p> <p>What do I have to do do make the WebView load an URL for the first click? And how can I debug such issues?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload