Google encourages developers to define custom permissions to protect our publicly available activities and custom data providers. The first step is to define such permissions in your manifest so that your app as well as all other apps can display pretty text for the permissions. Apps that merely use your custom permissions will display the text you defined in your app for each permission. One issue I discovered is that you should never define the permission group as an empty string (android:permissionGroup=””) or else the permission definition becomes invalid and no other app will be able to use it.
Custom permissions should also define a custom Permission Group if they are not part of one of the Android built-in groups, otherwise they will be displayed as part of a permission called “Default” and all your custom permissions will be shown as a comma separated list underneath it. For example:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mydomain.myapp" android:versionCode="1" android:versionName="1.0" > <permission-group android:name="com.mydomain.provider.permissions" android:label="@string/perm_text_group_mydomain_provider" /> <permission android:name="com.mydomain.provider.permission.ACCESS_DATA" android:permissionGroup="com.mydomain.provider.permissions" android:label="@string/perm_text_access_mydomain_provider" /> <permission android:name="com.mydomain.provider.permission.WRITE_DATA" android:permissionGroup="com.mydomain.provider.permissions" android:label="@string/perm_text_modify_mydomain_provider" /> <uses-permission android:name="com.mydomain.provider.permission.ACCESS_DATA" /> <uses-permission android:name="com.mydomain.provider.permission.WRITE_DATA" /> <application android:label="@string/app_name" android:description="@string/app_desc" android:icon="@drawable/app_icon" > <provider android:name="com.mydomain.MyProvider" android:authorities="com.mydomain.provider.myprovider" android:readPermission="com.mydomain.provider.permission.ACCESS_DATA" android:writePermission="com.mydomain.provider.permission.WRITE_DATA" android:exported="true" > </provider> </application> </manifest>
Once you have defined all your permissions, other apps can simply use them with <uses-permission> and their apps will use your string definitions when displaying them in Settings as part of managing the device’s apps.