pranavsethi96 pranavsethi96 - 1 year ago 94
Android Question

How to start an activity when a link is clicked in webview?

I am developing an android app, which has a webview in it..

I wanted to know how can I load up a specific activity (Eg. - abcd.Java) when a link in the web page is clicked...

I am comfortable in coding either in Web Document or through java and even both.

Thanks in advance :)


just using shouldOverrideUrlLoading:

private class MyWebViewClient extends WebViewClient {
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (url.equals("YOURLINK")) {
            Intent intent = new Intent(getContext(), YourActivity.class);
            return true; // Handle By application itself
            return true;