Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid : click link in a page within web view
    text
    copied!<p>I have included a web application within android web view , and there is a link in the webpage which opens some other site , when the link is clicked it works fine for the first click, however when clicked for the second time the website is not found , </p> <p>the code is :</p> <pre><code>@Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.contains("some site ")) { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(i); return true; } else { view.loadUrl(url); return false; } } </code></pre> <hr> <p>@THelper and @mikegr, thanks for the reply,</p> <p>Actually in my case i have a modal panel (JSF) in my web application which contains some buttons, on clicking the button i am opening some other site using javascript window.open() method which works fine in desktop browser, however, when i wrap this web application within android webview, everything works fine except when i first click this button i'm able to open the other site using the external browser, however on second click the webview tries to open this othersite within the webview instead of the external browser and i get website not found with the entire URL of the other site, this happens even when i logout and login again as the application launched is still running.</p> <p>also in my case after sometime when the application is idle i get the black screen.</p> <p>i surfed through the net and found simillar issue but that didn't help either , here is the link: </p> <p><a href="http://groups.google.com/group/android-for-beginners/browse_thread/thread/42431dd1ca4a9d98" rel="nofollow noreferrer">http://groups.google.com/group/android-for-beginners/browse_thread/thread/42431dd1ca4a9d98</a></p> <p><a href="https://stackoverflow.com/questions/4788461/handling-links-in-a-webview">handling links in a webview</a> ,</p> <p>any help and ideas would be very helpful for me, this is taking too long for me,</p> <p>since i'm trying to display my web application in the web view, i have only one activity, which contains code like this</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { // so that when launcher is clicked while the application is // running , the application doesn't start from the begnining } else { requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); // Show the ProgressDialog on this thread this.progressDialog = ProgressDialog.show(this, "Pleas Wait..", "Loading", true); browser = (WebView) findViewById(R.id.webview); browser.getSettings().setJavaScriptEnabled(true); browser.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { Log.i(TAG, "Finished loading URL: " +url); if (progressDialog.isShowing()) { progressDialog .dismiss(); } } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.contains("some site")) { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(i); return true; } else { view.loadUrl(url); return true; } } }); browser.loadUrl("mysite"); } } </code></pre>
 

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