Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the list of installed Browser Apps in an Android 7.0 running devices programmatically?

Before Android 7.0 I was able to retrieve the list of installed browser type applications and it's package name. Then, I upgrade to Android 7.0 and I am only able to retrieve Samsung's Internet browser, but not the other browser type applications such as Chrome .

Device Samsung Tab A

This is the code :

public static List<String> getListOfBrowser(Context context) {
    List<String> browserPackageName = new ArrayList<String>();
    try {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("http://www.google.com"));
        PackageManager pm = context.getPackageManager();
        List<ResolveInfo> browserList = pm.queryIntentActivities(intent, 0);
        for (ResolveInfo info : browserList) {
            browserPackageName.add(info.activityInfo.packageName);
            Log.e("BrowserList Info ",info.activityInfo.packageName+" total browser"+browserList.size());
        }
    } catch (Exception e) {
        e.printStackTrace();
        Log.e("BrowserList Info ",e.getMessage());
    }
    return browserPackageName;
}
like image 222
rahul chaube Avatar asked Jan 11 '18 14:01

rahul chaube


People also ask

How do I get a list of installed apps on android?

Go to Settings and find the App Management or Apps section, depending on your phone. If you can't locate it, simply perform a quick search within Settings. Once in App Management, tap on See All Apps or App Settings to see the list of apps installed on your device, excluding the system apps.

How do I know if an application is installed in android programmatically?

Call the below function appInstalledOrNot() with the package name of the app installed on the ANDROID Device as a string parameter. This function returns true if the app is installed otherwise returns false. super. onCreate(savedInstanceState);

How do you know app is installed or not?

If the user has installed the web app using the new Web APK functionality, it is possible to determine if your web app is installed. If you know the package name of your Web APK then you can use the context. getPackageManager(). getApplicationInfo() API to determine if it is installed.

What is the use of package manager in android?

Package Manager is a simple, yet powerful application, offering the following features: * A beautiful list view of System and User applications, together or separately. * Helps to do basic tasks such as Open app, show app info, visit PlayStore page, uninstall (User apps), etc.


1 Answers

If Android API level >= 23, then you can do like so:

List<ResolveInfo> browserList;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.MARSHMALLOW) {
    // gets all
    browserList = pm.queryIntentActivities(intent, PackageManager.MATCH_ALL);
    // only the defaults
    browserList = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
} else {
    browserList = pm.queryIntentActivities(intent, 0);
}
like image 150
AlexTa Avatar answered Oct 25 '22 16:10

AlexTa