1

How do we open an activity after clicking some specific link or button of a website which is from some website and open using webview?

  • refer this link : https://stackoverflow.com/questions/9387999/how-to-open-webview-link-to-new-activity – Sunil Kumar Jul 06 '17 at 06:58
  • Possible duplicate of [How to open WebView link to new activity?](https://stackoverflow.com/questions/9387999/how-to-open-webview-link-to-new-activity) – Andy Developer Jul 06 '17 at 07:07

1 Answers1

4

Use shouldOverrideUrlLoading to give the host application a chance to take over the control when a new url is about to be loaded in the current WebView. For more information shouldOverrideUrlLoading

Try this it will help you:

public class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    if (url.equals("url")) {
        Intent intent = new Intent(contxt, YourActivity.class);
        startActivity(intent);
        return true; // Handle By application itself
    } else {
        view.loadUrl(url);
        return true;
    }
}
}
Rishabh Maurya
  • 1,448
  • 3
  • 22
  • 40
AskNilesh
  • 67,701
  • 16
  • 123
  • 163