更新时间:2023-11-22 20:43:52
我通过检查用户是否已授予外部存储权限,如果未授予权限,则通过使用请求权限来解决问题:
I solved the problem by checking if the user has granted permission of external storage and request permision if not granted by using:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (this.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
this.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_REQUEST_CODE);
}
所有这些都是 android 特定的代码,因此驻留在 AndroidLauncher
类中.
All of this is android-specific code and thus resides in the AndroidLauncher
class.