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

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

    You can use checkSignatures to determine if an app is a system app or not.

    All system apps are signed with the same key.

    https://developer.android.com/reference/android/content/pm/PackageManager#checkSignatures(java.lang.String,%20java.lang.String)

    And signed with the system key is the "android" package.

        val checkPackage: String = "com.package.to.check"
        val systemPackageName = "android"
        if (packageManager.checkSignatures(systemPackageName, checkPackage) == PackageManager.SIGNATURE_MATCH) {
            Log.d("TUT", "System app")
        } else {
            Log.d("TUT", "Non-System app")
        }
    
    0 讨论(0)
提交回复
热议问题