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

后端 未结 13 1236
无人共我
无人共我 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:17

    This is a simplified and more efficient version of other responses listed here. It is more efficient if you just iterate directly over the ApplicationInfos.

        List applications = context.getPackageManager()
                .getInstalledApplications(PackageManager.GET_META_DATA);
        for(ApplicationInfo appInfo : applications){
            if((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0){
                // Not a system app
            }
        }
    

提交回复
热议问题