I have a webview in which a url is loaded, which has some url to be clickable, but the problem is when i click the links on page loaded in webview it opens in default browser, i want to open dialog containing all browsers when i click on link, which are in device, to ask to choose the browser and it should open in the browser selected ?
-
1Certainly! Go in your Settings, Manage Applications. Click the All tab, and then select Browser. You must then click the Clear Defaults button. Now next time that an application requires a browser (say, you click a link in your Twitter app) the Complete action using dialog will pop up and you can select Opera or chrome or whatever u want and tick the Use by default for this action box. – Shiv Feb 22 '13 at 04:55
3 Answers
Overriding the Default Click Behavior
when the user clicks on a link in the WebView the default behavior is to load whatever default app can handle the link. So if you click on a web URL, the browser will open to handle it. If you were trying to navigate between locally built web pages, you’d need to override this functionality. Luckily this is not difficult to handle. You can do it super quick by setting the WebViewClient of your WebView to a new instance of WebViewClient like so:
OnCreate:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webView = (WebView) findViewById(R.id.webView1);
WebViewClient viewClient = new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse(url));
startActivity(intent);
view.loadUrl(url);
return true;
}
};
webView.setWebViewClient(viewClient);
webView.loadUrl("http://www.google.com");
}
Check the below link for more info on WebViewClient

- 1
- 1

- 12,572
- 4
- 76
- 80
but the problem is when i click the links on page loaded in webview it opens in default browser
If you have selected
use by default this application checkbox
Then the android stops showing options list to user and continues opening link in selected default browser.
The only solution you can have is clear that preference by going into settings.And then onwards android will show you Complete action using List.
And if you want to go by complex way then you can use Javascript injection and invoke Android code when link is clicked which will programatically display browser list to user.
you can use PackageManager
and queryIntentActivityOptions()
to filter your activity out and get a list of other activities that the user can choose from.

- 27,808
- 7
- 60
- 75
@Neha it depends upon how many browsers are available in your mobile. for eg,if u have only default browser it redirects to that browser only. if u installed chrome browser next time run your app it ask choose browser option.

- 941
- 9
- 22