Android runtime permissions

Welcome! Forums Unity Plugins Mobile Speech Recognizer Android runtime permissions

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1400
    jphales
    Participant

    Upon upgrading to Unity 2018.3+, the plugin no longer functions. Although the android manifest is the same and the line:
    <uses-permission android:name=”android.permission.RECORD_AUDIO” />
    When installing the app on android, it no longer asks for “permission to record audio” and plugin doesn’t work.
    Haven’t checked iOS.
    Up to ~ 2018.2.6 it was fine.
    Does this have to do with Unity now packaging their own android sdk now?

    Stumped and really need help please.
    Thanks!
    Jon

    • This topic was modified 4 years, 9 months ago by PiotrPiotr.
    #1401
    PiotrPiotr
    Keymaster

    What do you mean by “own android sdk”?

    Are you using runtime permissions?
    https://docs.unity3d.com/Manual/android-RequestingPermissions.html

    #1403
    jphales
    Participant

    Thanks for the very quick response.
    Sorry, I meant the new “embedded JDK”

    I’m not using runtime permissions. Usually the app simply requests permission to use audio on install because of the permissions line in the android manifest – and it’s no longer doing so.

    I guess I can give the runtime permissions a try. I would just prefer the permissions popup on install.

    I’ll give it a try.

    #1404
    jphales
    Participant

    So, yes,

    Thanks for the response. I’m glad the plugin works, but for me was a pain to deal with permissions at runtime. Would much rather prefer on install. Don’t know why it changed.

    Thanks for your help!
    Jon

    #1405
    PiotrPiotr
    Keymaster

    Ask Google 🙂
    They changed it starting from Android 6.
    https://developer.android.com/guide/topics/permissions/overview

    #1423
    larryapple
    Participant

    Do you have a suggestion of how to go about requesting permission at run time?

    #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.

    #1425
    larryapple
    Participant

    Hi jphales!

    Thank you so much for the solution! Works great!

    Larry

    #2149
    CarinaO
    Participant

    Hello,

    I’m trying to launch the exemple scene and did change my manifest with the permissions needed and tried to use the solution proposed by jphales in the recordingCanvas.cs in the start method.
    The problem is that nothing happens when it reaches Permission.RequestUserPermission(Permission.Microphone); line even if it does say that i don’t have the permission that confirms it goes inside de condition. Could it be related to the manifest or do you see what could be the problem?

    Carina

    #2150
    Vana
    Participant

    Hello,
    this I added to SpeechRecognizerListener.cs Script to make it work:

    private void Start()
    {
      #if PLATFORM_ANDROID
      if (!Permission.HasUserAuthorizedPermission(Permission.Microphone))
      {
         Permission.RequestUserPermission(Permission.Microphone);
      }
      #endif
    }
    • This reply was modified 3 years, 7 months ago by Vana.
    #2154
    CarinaO
    Participant

    Thanks a lot it help a lot !

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.