Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get installed applications in Android and no system apps?

Tags:

I want to get all application which appears in the menu screen. But, now I only get the user installed apps or all the application (included the system application).

My current code is:

    final PackageManager pm = getActivity().getPackageManager();
    List<PackageInfo> apps = pm.getInstalledPackages(PackageManager.GET_META_DATA);

    ArrayList<PackageInfo> aux = new ArrayList<PackageInfo>();

    for (int i = 0; i < apps.size(); i++) {
        if (apps.get(i).versionName != null && ((apps.get(i).applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 1)) {
            aux.add(apps.get(i)); 
        }

With this code, I can get the user installed apps, and if I comment the 'if' instruction, I will get the system apps.

So, I want to get the user installed apps and apps like contacts, gallery and so on.

UPDATE:

    final PackageManager pm = getActivity().getPackageManager();
    Intent intent = new Intent(Intent.ACTION_MAIN, null);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    List<ResolveInfo> apps = pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);
like image 554
beni Avatar asked Jul 06 '13 15:07

beni


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 enable system apps on Android?

Go to Android Enterprise > Application > System App Activation Setting: Apply.

Why are my installed apps not showing?

Ensure the Launcher Does Not Have the App Hidden Your device may have a launcher that can set apps to be hidden. Usually, you bring up the app launcher, then select “Menu” ( or ). From there, you might be able to unhide apps. The options will vary depending on your device or launcher app.


1 Answers

final PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);

Using PackageInfo:

private boolean isSystemPackage(PackageInfo packageInfo) {
    return ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
}

Using ResolveInfo:

private boolean isSystemPackage(ResolveInfo resolveInfo) {
    return ((resolveInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
}

Using ApplicationInfo:

private boolean isSystemPackage(ApplicationInfo applicationInfo) {
    return ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
}

This filters the system package. See this question. Credits: Nelson Ramirez and Kenneth Evans.

like image 166
Barış Akkurt Avatar answered Sep 19 '22 19:09

Barış Akkurt