Zip
Zip

Reputation: 859

Android- How to get custom permission string defined in Manifest

<permission
        android:name="com.example.myPermission"
        android:protectionLevel="normal" />

If I defined a permission like this and use this permission to an activity A. Then I want to check if an app have this permission, so I use PackageManger and the checkPermission(permissionString, packageName) method to check. The problem is I don't want to use straight string for permissionName, is there any way I can get the permission string like Manifest.permission.xxxx?

Thanks in advance!!

Upvotes: 0

Views: 667

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006574

Well, there is no Manifest.permission value for your custom permission, because Manifest.permission is part of the platform, and ~1.5 billion Android devices do not know about your app.

You can try using a string resource for the permission name, referring to that resource both from <permission> and from your Java code.

Upvotes: 2

Related Questions