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:
PackageManager packageManager = context.getPackageManager();
Intent intent = new Intent(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) {
String name = 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.
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("http://www.aurl.com"))
val browsersList = packageManager.queryIntentActivities(browserIntent,
PackageManager.MATCH_ALL)
browsersList.forEach {
val packageName = it.activityInfo.packageName
}
Post a Comment for "How Get List Of Web Browsers In System"