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);
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.
Go to Android Enterprise > Application > System App Activation Setting: Apply.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With