Android permissions in Unity
Understand Android permissions and how to work with them in Unity.
Read time 3 minutesLast updated 19 days ago
To get permission to access device features or data outside of your Unity application's sandbox, there are two stages:
- At build time, declare the permission in the application's Android App Manifest.
- At runtime, request permission from the user.
For some permissions, Unity automatically handles both the build-time Android App Manifest entries and runtime permission requests. For more information, see Unity-handled permissions.
Declare permissions
An Android application can only request the user for permission to use device features or data that it declares in its Android App Manifest. This is the build-time stage of Android permission handling. For information on how to declare permissions, see Declare permissions for an application.
Runtime permissions
You can request runtime permissions at any time while the application is running. It's best practice to request permission for restricted data or a device feature when the application requires the data/feature for the first time. You should also show the user a message that explains why the application requires the data/feature before you send the request. This is important to give users context so they are less likely to deny the permission out of confusion.
For information on how to request permission at runtime, see Request runtime permissions.
Unity-handled permissions
Depending on the Player Settings and Unity APIs that the application uses, Unity automatically adds some required permissions to the Android App Manifest and sends permission requests at runtime. This also applies to any plug-ins that the application uses.
To stop Unity from automatically sending permission requests at runtime, add to the Android App Manifest. This is useful if you want to provide information about why the application requires each permission before the user sees the permission request. In this case, you need to send the permission requests manually. For more information, see Request runtime permissions.
unityplayer.SkipPermissionsDialogThe following list explains which permissions Unity handles automatically:
- If the application uses vibration such as Handheld.Vibrate, Unity adds the permission to the Android App Manifest.
VIBRATE - If the application uses the Application.internetReachability property, Unity adds the permission to the Android App Manifest.
ACCESS_NETWORK_STATE - If the application uses a location API such as LocationService, Unity adds the permission to the Android App Manifest and requests permission from the user the first time that the application uses location.
ACCESS_FINE_LOCATION - If the application uses the WebCamTexture class Unity adds the permission to the Android App Manifest and requests permission from the user the first time that the application uses
CAMERA.WebCamTexture - If the application uses the Microphone class adds the permission to the Android App Manifest and requests permission from the user the first time that the application uses
RECORD_AUDIO.Microphone