且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我该如何检查,如果一个应用程序在Android的非系统应用程序吗?

更新时间:2023-11-14 10:51:58

嗯,这是我认为一个草率的解决方案(如果的 /数据/应用程序的是不是所有设备上的应用程序目录? ),但仔细搜索后,这是我想出了:

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
    }
}