Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find default browser set on android device

Tags:

Is there any way to find out which browser is set as a default browser on android device? On android device there may be multiple browsers installed but out of which only one set as a default. I need to find it out programmatically.

Thanks in advance. Early response is appreciated..

like image 500
kkarmalkar Avatar asked May 12 '14 14:05

kkarmalkar


People also ask

How do I find out what my default browser is on my phone?

Users, however, have the option to change the default browser by following a few simple steps. -Open the Settings app from the phone's menu. -Next, tap on 'Apps' and select the Default Apps option. -Here, you will see your phone's current default browser along with another browser installed on your app.


2 Answers

This code may help you:

Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse("http://"));   ResolveInfo resolveInfo = getPackageManager().resolveActivity(browserIntent,PackageManager.MATCH_DEFAULT_ONLY);  // This is the default browser's packageName String packageName = resolveInfo.activityInfo.packageName; 

and if wanna start it, do as follows:

startActivity(getPackageManager().getLaunchIntentForPackage(packageName)); 
like image 139
exloong Avatar answered Oct 31 '22 18:10

exloong


You are welcome to use PackageManager and resolveActivity() to attempt to determine what activity (in what app) will handle a particular Intent. However, this may indicate that the chooser will handle the request, because there is no current default (e.g., user just installed a new browser, and so the chooser will appear for the next Web browser request).

like image 21
CommonsWare Avatar answered Oct 31 '22 19:10

CommonsWare