Reply To: Android runtime permissions

Welcome! Forums Unity Plugins Mobile Speech Recognizer Android runtime permissions Reply To: Android runtime permissions

#1424
jphales
Participant

Hi larryapple!
It’s simple enough. You can take a look at the Unity link above.
You can do it as needed, or even simply at the start of your app by dropping the following in a script.

Make sure you’re at the top you are :
#if PLATFORM_ANDROID
using UnityEngine.Android;
#endif

And then, in any function, could even be in your start function include:
#if PLATFORM_ANDROID
if (!Permission.HasUserAuthorizedPermission(Permission.Microphone))
{
Permission.RequestUserPermission(Permission.Microphone);
}
#endif

That should bring up the default android permission dialogue.