Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I dynamically detect whether my application is system or normal?

Tags:

android

How do I differentiate between a system app and a normal app ? I looked through android PackageManager and could not find any.

Edit: I want to differentiate via code.

if(system app) {
  //do something
}
else{
   //do nothing
}
like image 696
Vinoth Avatar asked May 18 '11 11:05

Vinoth


People also ask

How do you check if app is system app or not?

A user can uninstall such applications normally from the Settings application. One can check if an application is a System application or not using “ApplicationInfo. FLAG_SYSTEM”.

Where can I find System Apps on Android?

Just search for the app on the Play Store and click on the Install button. You can install it either as system apps or as user apps. System apps are pre-installed apps in the system partition with your ROM. In other words, a system app is simply an app placed under '/system/app' folder on an Android device.


1 Answers

You could try using the flags available in the ApplicationInfo class (android.conent.pm). For example:

...
PackageManager pm = getPackageManager();
List<ApplicationInfo> installedApps = pm.getInstalledApplications(0);

for (ApplicationInfo ai: installedApps) {

    if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
        // System app - do something here
        ...
    } else {
        // User installed app?
    }
}
like image 83
Claire Swinson Avatar answered Nov 16 '22 00:11

Claire Swinson