Android Dynamic Permissions Popup
Dynamically Obtain System Permissions
For the complete list of permissions, go to the official website. In the following image, the READ_PHONE_STATE
permission is android.permission.READ_PHONE_STATE
.
info
For the list of Android permissions required for different channels, see Android Channel Permission Description.
Customize the Style and Language of the Dialog Box
- Configure the launch interface in
AndroidManifest
. This{YOUR_START_ACTIVITY}
is the jump page after the permission application, which the game team must configure.
<activity android:name="com.intlgame.tools.permission.PermissionGrantActivity">
<meta-data android:name="INTLSDK_GAME_ACTIVITY_CLASSNAME" android:value="{YOUR_START_ACTIVITY}"/>
<meta-data android:name="INTLSDK_DENY_SETTINGS_TYPE" android:value="setting" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
- Add the following configurations in
res/strings.xml
to set the permission prompt.
caution
If you do not add the following configurations, permissions are directly granted. This does not comply with Google Play regulations and may cause the review to fail.
<string name="intl_permission_confirm">Confirm</string>
<string name="intl_permission_cancel">Cancel</string>
<string name="intl_permission_settings">Settings</string>
<string name="intl_always_denied_warning">Please go to the settings interface and grant the necessary permissions. Otherwise, you will not be able to access the game.</string>
<string name="intl_permission_grant_warning"> Reasons for requesting xxx permissions: 1. The game requires camera permission to save videos. 2. The game requires read and write permissions to read and write files.</string>
<string name="intl_permission_title">INTL</string>
<!-- Configure the permissions that you want to apply (optional) -->
<string-array name="intl_permission_granted_list">
<item>android.permission.CAMERA</item>
<item>android.permission.INTERNET</item>
<item>android.permission.WRITE_EXTERNAL_STORAGE</item>
<item>android.permission.READ_EXTERNAL_STORAGE</item>
</string-array>
- (Optional) Add the following configurations in
res/styles.xml
to set the style of the dialog box. For more styles, see https://developer.android.com/reference/android/R.styleable.html#Theme.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="INTLPermissionTheme" parent="@android:style/Theme.DeviceDefault.Light.Dialog">
<!-- Set background here -->
<item name="android:windowBackground">@android:color/white</item>
<item name="android:windowNoTitle">false</item>
<!-- Change the background color of the heading at the top here, you may select the color you like or set an image as the background -->
<item name="android:topDark">@android:color/holo_purple</item>
<!-- Change the text background color here -->
<item name="android:centerDark">@android:color/background_light</item>
<item name="android:windowIsTranslucent">false</item>
</style>
</resources>