1

How can I get a list of non-system apps for my RecyclerView?

I want to filter my list not to include system apps

  • The current app count for system apps is 353 but it should be around 15-20
  • I have used packageManager.getInstalledPackages(0) to get the all the installed packages in the device and to differentiate between system apps and third party apps i have used applicationInfo.flags and package.ApplicationInfo.FLAG_SYSTEM)==0
  • Here is a ScreenShot

Please help!!

Any language, java or kotlin is appreciated. THANKS IN ADVANCE..

m'hd semps
  • 564
  • 4
  • 14
Sandeep
  • 23
  • 4
  • Besides "unwanted", what is the criteria for what you do and do not want in your list? For example, are you trying to create a launcher? If so, `getInstalledPackages()` is not the right approach. – CommonsWare Aug 24 '20 at 12:11

1 Answers1

2

Non systems apps can be identified by having a launch intent if the app has no launch intent then its a system app check

ArrayList<ApplicationInfo> thirdPartyApps = new ArrayList<>();
PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for(ApplicationInfo packageInfo:packages){
    if( pm.getLaunchIntentForPackage(packageInfo.packageName) != null ){
                String currAppName = pm.getApplicationLabel(packageInfo).toString();
               //This app is a non-system app
               thirdPartyApps.add(packageInfo);
    }
    else{
        //System App
    }
}
m'hd semps
  • 564
  • 4
  • 14