Using data from context providers or requesting Google Photos read permission?

后端 未结 6 1289
陌清茗
陌清茗 2020-12-05 07:34

My app allows users to import their photos and videos from other apps. Now that Google replaced Google+ Photos with Google Photos, couple of things broke for me. One of thes

6条回答
  •  [愿得一人]
    2020-12-05 07:53

    You need to set permissions explicitly to all packages match your intent. It happens in Android 4.4 usually.

    you can use this utility to do that :

    List resInfoList = getContext().getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
            for (ResolveInfo resolveInfo : resInfoList) {
                String packageName = resolveInfo.activityInfo.packageName;
                getContext().grantUriPermission(packageName, imageFileUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
            }
    

提交回复
热议问题