权限拒绝需要android.permission.READ_EXTERNAL_STORAGE或grantUriPermission()

时间:2017-05-16 06:26:31

标签: android permissions android-external-storage

您好,这很奇怪,我在我的清单+中为Android 23+代码提供权限。它看起来像:

清单文件:

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

代码:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);
    requestPermissions(this,new String[]{
            Manifest.permission.ACCESS_FINE_LOCATION,
            Manifest.permission.ACCESS_COARSE_LOCATION,
            Manifest.permission.CAMERA,
            Manifest.permission.WRITE_EXTERNAL_STORAGE,
            Manifest.permission.READ_EXTERNAL_STORAGE},   1001);
    }

我正在尝试保存照片(在此期间我将一些数据插入数据库)我收到错误:

   E/DatabaseUtils: Writing exception to parcel
                                                    java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/fs_id from pid=31226, uid=10131 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()

奇怪的是,app似乎工作正常,但我在日志中遇到了这个错误。

0 个答案:

没有答案