ZlwAudioRecorder icon indicating copy to clipboard operation
ZlwAudioRecorder copied to clipboard

Android 10 录音失败

Open 298068845 opened this issue 4 years ago • 11 comments

在Android 9或以下的设备录音没有问题,在Android 10上录音会提示录音失败

298068845 avatar Jun 17 '20 07:06 298068845

我查了相关文档https://developer.android.com/guide/topics/media/mediarecorder

注意:在搭载 Android 9(API 级别 28)或更高版本的设备上,在后台运行的应用将无法访问麦克风。因此,您的应用只在以下两种情况下才应录制音频:当其位于前台时,或者您在前台服务中添加了 MediaRecorder 实例时。

应该是录制使用了service的缘故,请问后续会优化适配Android10吗?

298068845 avatar Jun 17 '20 07:06 298068845

I had the same problem on the Android Q,but I found that it was because of the storage path is null;You can set the path of the folder with the Android Q storage permission ! I hope this can help you!

ruancw avatar Jun 19 '20 02:06 ruancw

I had the same problem on the Android Q,but I found that it was because of the storage path is null;You can set the path of the folder with the Android Q storage permission ! I hope this can help you!

I have been set the storage path with "RecordManager.changeRecordDir(getCacheDir().getAbsolutePath()+"/")",so I think is not path‘ s problem

298068845 avatar Jun 19 '20 03:06 298068845

You need to adapt the Android Q storage path,because on Android Q the storage policy behavior has changed

------------------ 原始邮件 ------------------ 发件人: "vlc"<[email protected]>; 发送时间: 2020年6月19日(星期五) 中午11:07 收件人: "zhaolewei/ZlwAudioRecorder"<[email protected]>; 抄送: "赤枫孤雁"<[email protected]>;"Comment"<[email protected]>; 主题: Re: [zhaolewei/ZlwAudioRecorder] Android 10 录音失败 (#44)

I had the same problem on the Android Q,but I found that it was because of the storage path is null;You can set the path of the folder with the Android Q storage permission ! I hope this can help you!

I have been set the storage path with "ecordManager.changeRecordDir(getCacheDir().getAbsolutePath()+"/")",so I think is not path‘ s problem

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

ruancw avatar Jun 19 '20 03:06 ruancw

我在小米9Q 没有复现, 你们用的什么机型?

zhaolewei avatar Jul 03 '20 09:07 zhaolewei

I have the same issue did anyone found the solution ?? , in Android 10 its not working

omardhanish avatar Jul 09 '20 02:07 omardhanish

Android10以后不能写入在项目自有存储空间以外的地方,像你这个录音项目默认的存储路径,会写入失败

298068845 avatar Jul 13 '20 01:07 298068845

Actually, you can use "context.getExternalFilesDir(Environment.DIRECTORY_MUSIC)" in all Android Platforms.

A-10ng avatar Aug 13 '20 09:08 A-10ng

我查了相关文档https://developer.android.com/guide/topics/media/mediarecorder

注意:在搭载 Android 9(API 级别 28)或更高版本的设备上,在后台运行的应用将无法访问麦克风。因此,您的应用只在以下两种情况下才应录制音频:当其位于前台时,或者您在前台服务中添加了 MediaRecorder 实例时。

应该是录制使用了service的缘故,请问后续会优化适配Android10吗?

一般录音也就是在前台吧?您的意思是说如果应用不可见的情况下录音会出问题吗?

oudengding avatar Aug 28 '20 12:08 oudengding

application里添加 android:requestLegacyExternalStorage="true"

liylmn avatar Sep 16 '20 05:09 liylmn

android 10以后录音没有声音,不知道什么问题

linchunxiao100 avatar Feb 26 '21 06:02 linchunxiao100