Welcome! › Forums › Unity Plugins › Mobile Speech Recognizer › Android runtime permissions
- This topic has 10 replies, 5 voices, and was last updated 4 years, 4 months ago by CarinaO.
-
AuthorPosts
-
March 5, 2019 at 7:47 pm #1400jphalesParticipant
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 5 years, 5 months ago by Piotr.
March 5, 2019 at 7:54 pm #1401PiotrKeymasterWhat do you mean by “own android sdk”?
Are you using runtime permissions?
https://docs.unity3d.com/Manual/android-RequestingPermissions.htmlMarch 5, 2019 at 8:36 pm #1403jphalesParticipantThanks 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.
March 5, 2019 at 11:26 pm #1404jphalesParticipantSo, 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!
JonMarch 6, 2019 at 3:12 pm #1405PiotrKeymasterAsk Google 🙂
They changed it starting from Android 6.
https://developer.android.com/guide/topics/permissions/overviewMarch 26, 2019 at 3:18 am #1423larryappleParticipantDo you have a suggestion of how to go about requesting permission at run time?
March 26, 2019 at 5:40 pm #1424jphalesParticipantHi 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;
#endifAnd then, in any function, could even be in your start function include:
#if PLATFORM_ANDROID
if (!Permission.HasUserAuthorizedPermission(Permission.Microphone))
{
Permission.RequestUserPermission(Permission.Microphone);
}
#endifThat should bring up the default android permission dialogue.
March 26, 2019 at 7:58 pm #1425larryappleParticipantHi jphales!
Thank you so much for the solution! Works great!
Larry
August 4, 2020 at 6:46 am #2149CarinaOParticipantHello,
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
August 4, 2020 at 7:56 am #2150VanaParticipantHello,
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 4 years, 4 months ago by Vana.
August 4, 2020 at 10:45 am #2154CarinaOParticipantThanks a lot it help a lot !
-
AuthorPosts
- You must be logged in to reply to this topic.