Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android 11 存储权限问题导致录音失败 #75

Open
hwf452 opened this issue Nov 22, 2023 · 0 comments
Open

android 11 存储权限问题导致录音失败 #75

hwf452 opened this issue Nov 22, 2023 · 0 comments

Comments

@hwf452
Copy link

hwf452 commented Nov 22, 2023

android 11 存储权限问题,在targetSdkVersion >=30 的时候无法创建临时文件导致录音失败,
建议将临时文件路径配置为可自定义,或者为缓存目录

RecordHelper 要改缓存目录为

String fileDir = String.format(Locale.getDefault(), "%s/Record/", this.currentConfig.getRecordDir());

就可以了

/**
* 根据当前的时间生成相应的文件名
* 实例 record_20160101_13_15_12
*/
private String getTempFilePath() {
String fileDir = String.format(Locale.getDefault(), "%s/Record/", this.currentConfig.getRecordDir());
if (!FileUtils.createOrExistsDir(fileDir)) {
Logger.e(TAG, "文件夹创建失败:%s", fileDir);
}
String fileName = String.format(Locale.getDefault(), "record_tmp_%s", FileUtils.getNowString(new SimpleDateFormat("yyyyMMdd_HH_mm_ss", Locale.SIMPLIFIED_CHINESE)));
return String.format(Locale.getDefault(), "%s%s.pcm", fileDir, fileName);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant