简体   繁体   English

将 Bitmap 图像保存到内部存储 - 权限被拒绝

[英]Save Bitmap image to internal storage - Permission denied

Solved by adding this code:通过添加此代码解决:

ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},1);

After going over many posts about this, I'm still not able to solve the error.在浏览了很多关于此的帖子后,我仍然无法解决该错误。

Error: Permission Denied.错误:权限被拒绝。 (When saving a photo) (保存照片时)

I'm using this code to see if the permission is granted, and it's not granted.我正在使用此代码查看是否授予了权限,并且未授予权限。

int result = ContextCompat.checkSelfPermission(ClassifierActivity.this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (result == PackageManager.PERMISSION_GRANTED){
  Toast.makeText(ClassifierActivity.this, "Permission granted..", Toast.LENGTH_SHORT).show();
} else {
  Toast.makeText(ClassifierActivity.this, "Permission NOT granted..", Toast.LENGTH_SHORT).show();
}

I've added this code to the Manifest (and it doesn't work):我已将此代码添加到清单中(但它不起作用):

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Solved by adding this code:通过添加此代码解决:

ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM