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

后端 未结 13 1240
无人共我
无人共我 2020-11-28 22:51

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

13条回答
  •  一向
    一向 (楼主)
    2020-11-28 23:16

    There are 2 type of Non - system applications :

    1. Apps downloaded from Google Play Store
    2. Preloaded apps by device manufacturer

    This code will return a list of all above applications:

    ArrayList mAllApp = 
            mPackageManager.getInstalledApplications(PackageManager.GET_META_DATA);
    
    for(int i = 0; i < mAllApp.size(); i++) {
        if((mAllApp.get(i).flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
             // 1. Applications downloaded from Google Play Store
            mAllApp1.add(mAllApp.get(i));
        }
    
        if((mAllApp.get(i).flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
            // 2. Applications preloaded in device by manufecturer
            mAllApp1.add(mAllApp.get(i));
        }
    }
    

提交回复
热议问题