loonix / another_audio_recorder

(Null-Safe + V2) Audio Record Plugin that supports record, pause, resume, stop, and provide access to audio level metering properties average power peak power.
https://pub.dev/packages/another_audio_recorder
MIT License
5 stars 8 forks source link

android 13 (API level 33) Permission issue #9

Closed Hitesh2812 closed 1 year ago

Hitesh2812 commented 1 year ago

Getting AnotherAudioRecorder.hasPermissions always false in android 13 (API level 33). So can't able to start recording.

loonix commented 1 year ago

does it give you any errors?

shide1989 commented 1 year ago

Having same issue, seems to be related to the RequestPermissionHandler :

D/RequestPermissionHandler( 1161): parsing result
D/RequestPermissionHandler( 1161): result-1
D/RequestPermissionHandler( 1161): onRequestPermissionsResult -false
D/VRI[MainActivity]( 1161): onFocusEvent true
D/VRI[MainActivity]( 1161): send msg MSG_WINDOW_FOCUS_CHANGED with caller android.view.ViewRootImplExtImpl.markAndDumpWindowFocusChangeMsg:956 
android.view.ViewRootImpl.windowFocusChanged:9837 
android.view.ViewRootImpl$WindowInputEventReceiver.onFocusEvent:9550 android.os.MessageQueue.nativePollOnce:-2 android.os.MessageQueue.next:349 android.os.Looper.loopOnce:186 android.os.Looper.loop:351 android.app.ActivityThread.main:8399 java.lang.reflect.Method.invoke:-2 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run:584 com.android.internal.os.ZygoteInit.main:1013 <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack> 
shide1989 commented 1 year ago

this issue seems to happens on recent version on android, maybe an update is needed on the permissions management

loonix commented 1 year ago

Might be missing some permission, I guess Google as changed again. Are you requesting the permissions on your app? which ones?

shide1989 commented 1 year ago

yes, I'm requesting the await AnotherAudioRecorder.hasPermissions method

shide1989 commented 1 year ago

using the permission_handler flutter permissions plugin, I found this info :


  /// Permission for accessing external storage.
  ///
  /// Depending on the platform and version, the requirements are slightly
  /// different:
  ///
  /// **Android:**
  /// - On Android 13 (API 33) and above, this permission is deprecated and
  /// always returns `PermissionStatus.denied`. Instead use `Permission.photos`,
  /// `Permission.video`, `Permission.audio` or
  /// `Permission.manageExternalStorage`. For more information see our
  /// [FAQ](https://pub.dev/packages/permission_handler#faq).
  /// - Below Android 13 (API 33), the `READ_EXTERNAL_STORAGE` and
  /// `WRITE_EXTERNAL_STORAGE` permissions are requested (depending on the
  /// definitions in the AndroidManifest.xml) file.
  ///
  /// **iOS:**
  /// - Access to folders like `Documents` or `Downloads`. Implicitly granted.
  static const storage = Permission._(15);

I ended up using this code :

      if (!await Permission.audio.request().isGranted) {...}

Maybe it would be interesting use this plugin as dependency

loonix commented 1 year ago

I use that plugin as well maybe its because I didn't got that problem. I don't really like to add more dependencies to the project

loonix commented 1 year ago

It should all work now on the latest version, thanks. Please let me know otherwise