/ storage / emulated / 0 / ...(权限被拒绝)仅在Google相册应用中

时间:2019-02-21 22:39:00

标签: android android-permissions

我正在尝试从Note 8手机上传图像文件。这就是我创建意图选择器的方式

private Intent createIntentChooser(Uri fileUri) {

        List<Intent> cameraIntents = new ArrayList<Intent>();
        Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
        PackageManager packageManager = mActivity.getPackageManager();
        List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);
        for (ResolveInfo res : listCam) {
            String packageName = res.activityInfo.packageName;
            Intent intent = new Intent(captureIntent);
            intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
            intent.setPackage(packageName);
            cameraIntents.add(intent);
        }


        // Filesystem.
        final Intent galleryIntent = new Intent();
        galleryIntent.setType("image/*");


        galleryIntent.setAction(Intent.ACTION_PICK);
        //the get content action would open up the documents view in kitkat
//          galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
        galleryIntent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        // Chooser of filesystem options.
        final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Source");

        // Add the camera options.
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[]{}));


        return chooserIntent;
    }

我看到三个应用程序可供选择。 1)三星相机应用 2)三星画廊 3)Google相册应用

当我选择以上任一选项时,我都能在IV中正确显示图像,但是当我尝试上传Google相册选项时,显示(权限被拒绝)。

当我尝试访问文件以将其转换为多部分时出现此错误。

Google相册应用需要某些特殊权限吗?

我也在使用FileProvider

<provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="com.seed.iontime.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths" />
        </provider>

我的文件路径xml是

<paths >
    <external-path name="iontime_images" path="Android/data/com.seed.iontime/files/Pictures" />
</paths>

0 个答案:

没有答案