Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I check if an app is a non-system app in Android?

I am getting a list of ApplicationInfo Objects with packageManager.getInstalledApplications(0) and attempting to categorize them by whether or not they are a system application.

For a while I have been using the technique described here, however after seeing that in my application, some of the apps were not in the non-system apps list (such as Facebook, which when available asks the system to install itself on the SD card). After next reading the actual documentation for ApplicationInfo.FLAG_SYSTEM, and understanding that it doesn't actually filter system apps, I am now looking for a new approach.

My guess is that there is a large gap between UIDs of System and non-system apps that I can gather to make this distinction, but as of yet I have not found an answer. I also looked into other flags, such as ApplicationInfo.FLAG_EXTERNAL_STORAGE, however I am supporting API 1.5.

Does anyone have a real solution to this (not involving FLAG_SYSTEM)?

like image 703
Phil Avatar asked Jan 09 '12 06:01

Phil


People also ask

How do you turn an Android app into a system app?

First create a folder for your app ( Let say MyTestApp) inside packages/apps/ of your android AOSP downloaded source code. Then create a Android.mk file inside the folder(MyTestApp). Step 2 open Android.mk file and add folowing code Snippet and save this mk file. PRODUCT_PACKAGES tag at the bottom MyTestApp.

What is non system app?

If an Application is a non-system application it must have a launch Intent by which it can be launched. If the launch intent is null then its a system App. Example of System Apps: "com.


1 Answers

PackageManager pm = mcontext.getPackageManager(); List<PackageInfo> list = pm.getInstalledPackages(0);  for(PackageInfo pi : list) {     ApplicationInfo ai = pm.getApplicationInfo(pi.packageName, 0);      System.out.println(">>>>>>packages is<<<<<<<<" + ai.publicSourceDir);      if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {         System.out.println(">>>>>>packages is system package"+pi.packageName);               } } 
like image 69
Nitin Avatar answered Sep 23 '22 20:09

Nitin