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

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

    Well, it's a sloppy solution in my opinion (what if /data/app isn't the apps directory on all devices?), but after a thorough search, this is what I have come up with:

    for (ApplicationInfo ai : appInfo) {
        if (ai.sourceDir.startsWith("/data/app/")) {
            //Non-system app
        }
        else {
            //System app
        }
    }
    

提交回复
热议问题