Reputation: 608
I have an issue with Android 6.0 Marshmallow. when I try to use the microphone and record user input, I get the following error.
12-09 18:26:42.226 204-10957/? W/ServiceManager: Permission failure: android.permission.RECORD_AUDIO from uid=10274 pid=757
12-09 18:26:42.226 204-10957/? E/: Request requires android.permission.RECORD_AUDIO
12-09 18:26:42.226 204-10957/? E/AudioFlinger: openRecord() permission denied: recording not allowed
12-09 18:26:42.226 757-1251/com.facebook.singApp E/AudioRecord: AudioFlinger could not create record track, status: -1
12-09 18:26:42.228 204-1253/? I/AudioFlinger: AudioFlinger's thread 0xafa40000 ready to run
And the application crashs, it happends only on Android 6.0 Marshmallow, all other platforms works prefectly. In android manifest I already added this code part:
<uses-permission android:name="android.permission.RECORD_AUDIO" android:maxSdkVersion="1" />
And on Unity I added the following code: (I know it's for webplayers but I figure, what the hack)
private IEnumerator mobilePremissions()
{
yield return Application.RequestUserAuthorization(UserAuthorization.Microphone | UserAuthorization.Microphone);
if (Application.HasUserAuthorization(UserAuthorization.WebCam | UserAuthorization.Microphone)) {
Debug.Log ("Great");
ViewerSwitchSence.Recording();
} else {
Debug.Log ("Crapping");
}
}
I don't know why Unity doesn't promot user for authorization at click time, that's what is expected on Android 6.0 Marshmallow.
Thanks ahead for your help.
Upvotes: 0
Views: 2666
Reputation: 608
Alright, solved this issue.
If you are getting the same problem, update to lastest Unity, however, if you already added android.permission.RECORD_AUDIO
to your manifest.
Make sure you delete this line from manifest, it will collide will Unity self added permissions and cause the application to crash on microphone request.
Hope it helps someone.
Upvotes: 1