错误:Uid 10087无权访问uri 0

时间:2018-09-01 18:31:55

标签: android permissions uri

我正在学习Android。 我想从图库中加载图片。 但是出了点问题

请帮助。...

与我相似enter link description here

这是我的错误代码 我认为它的意思是“我无法触摸我的尿液” 但我检查了清单

这是错误代码。

  

原因:java.lang.SecurityException:Uid 10087没有uri 0的权限@ content://com.google.android.apps.photos.contentprovider/-1/1/内容%3A%2F%2Fmedia%2Fexternal%2Ffile%2F116 / ORIGINAL / NONE / 1817194500                         在android.os.Parcel.readException(Parcel.java:1684)                         在android.os.Parcel.readException(Parcel.java:1637)                         在android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:3101)                         在android.app.Instrumentation.execStartActivity(Instrumentation.java:1518)                         在android.app.Activity.startActivityForResult(Activity.java:4225)                         在android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:757)                         在android.app.Activity.startActivityForResult(Activity.java:4183)                         在android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:744)                          at com.example.z2_sooodt.syslet_2018_summer.pre_startActivity.onActivityResult(pre_startActivity.java:220)                         在android.app.Activity.dispatchActivityResult(Activity.java:6932)

这是我清单的一部分

<manifest...
<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-feature android:name="android.hardware.camera" android:required="true"/>
.... </application
<provider
    android:name="android.support.v4.content.FileProvider"
    android:authorities="com.example.z2_sooodt.syslet_2018_summer.filepaths"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/filepaths" />
    </provider>
</application>

还有一部分代码

private Uri mImage;
private ImageView iview;
private String absoultePath;
private static final int PICK_FROM_CAMERA = 0;
private static final int PICK_FROM_ALBUM = 1;
private static final int CROP_FROM_IMAGE = 2;
public int FuckingFLAG;

private String[] permissions = {Manifest.permission.READ_EXTERNAL_STORAGE, 
Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};


@Override
    public void onClick(View view) {

            final DialogInterface.OnClickListener cameraListener = new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    Intent intent = new Intent(Intent.ACTION_PICK);
                    intent.setType(android.provider.MediaStore.Images.Media.CONTENT_TYPE);
                    intent.setData(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                    startActivityForResult(intent, PICK_FROM_ALBUM);
                }
            };

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != RESULT_OK) {
        return;
    }

    if(requestCode == PICK_FROM_ALBUM) {
            if (data == null)
                return;
            mImage = data.getData();
        Intent cropPictureIntent = new Intent("com.android.camera.action.CROP");
        cropPictureIntent.setDataAndType(mImage, "image/*");
        cropPictureIntent.putExtra("output", mImage);

        cropPictureIntent.putExtra("outputX", 256);
        cropPictureIntent.putExtra("outputY", 256);


        cropPictureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        cropPictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);

        startActivityForResult(cropPictureIntent, CROP_FROM_IMAGE); /*This is the Error 
(at com.example.z2_sooodt.syslet_2018_summer.pre_startActivity.onActivityResult(pre_startActivity.java:220) )  **///


    }

1 个答案:

答案 0 :(得分:0)

什么是模拟器或电话API?您是否要通过电话首选项设置/应用程序和通知/您的应用程序/权限来授予您的应用程序权限?