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
)?
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.
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.
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); } }
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