Skip to content Skip to sidebar Skip to footer

How Get List Of Web Browsers In System

How can I get programmatically a list of web-browsers in system? Update: I know what manifestfile of that applications must have attribute android:scheme='http' or android:scheme='

Solution 1:

You can check, for example, what Activities in the system can handle a specific Intent, like this:

PackageManagerpackageManager= context.getPackageManager();
    Intentintent=newIntent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("http://www.google.com"));
    List<ResolveInfo> list = packageManager.queryIntentActivities(intent,
            PackageManager.MATCH_DEFAULT_ONLY);
            for (ResolveInfo info : list) {
                Stringname= info.name;
            }

Hope this will work for you.

Solution 2:

You can use a package manager along with an intent to open a browser to get the list of all the browsers in the device. To get the package name of the app, you can use it.activityInfo.packageName, where it is a list item.

valbrowserIntent= Intent(Intent.ACTION_VIEW, Uri.parse("http://www.aurl.com"))
valbrowsersList= packageManager.queryIntentActivities(browserIntent, 
                   PackageManager.MATCH_ALL)
browsersList.forEach {
    valpackageName= it.activityInfo.packageName
}

Post a Comment for "How Get List Of Web Browsers In System"