From d050e97f20b15c643e9a37892d53f1f7805ce3b0 Mon Sep 17 00:00:00 2001 From: Ivan Terekhin Date: Thu, 26 Mar 2020 18:29:05 +0300 Subject: [PATCH] Fix for content provider Update ShareExtendPlugin.java Update ShareExtendPlugin.java Update ShareExtendPlugin.java Update ShareExtendPlugin.java --- .../java/com/zt/shareextend/ShareExtendPlugin.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/zt/shareextend/ShareExtendPlugin.java b/android/src/main/java/com/zt/shareextend/ShareExtendPlugin.java index e0bdc93..066bf15 100644 --- a/android/src/main/java/com/zt/shareextend/ShareExtendPlugin.java +++ b/android/src/main/java/com/zt/shareextend/ShareExtendPlugin.java @@ -3,6 +3,7 @@ import android.Manifest; import android.content.Intent; import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; import android.net.Uri; import java.io.File; @@ -71,6 +72,7 @@ private void share(List list, String type, String sharePanelTitle, Strin shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject); + ArrayList uriList = new ArrayList<>(); if ("text".equals(type)) { shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT, list.get(0)); @@ -83,7 +85,6 @@ private void share(List list, String type, String sharePanelTitle, Strin } } - ArrayList uriList = new ArrayList<>(); for (String path : list) { File f = new File(path); Uri uri = ShareUtils.getUriForFile(mRegistrar.activity(), f); @@ -105,12 +106,17 @@ private void share(List list, String type, String sharePanelTitle, Strin shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uriList); } } - startChooserActivity(shareIntent, sharePanelTitle); + startChooserActivity(uriList.get(0), shareIntent, sharePanelTitle); } - private void startChooserActivity(Intent shareIntent,String sharePanelTitle) { + private void startChooserActivity(Uri uri, Intent shareIntent,String sharePanelTitle) { Intent chooserIntent = Intent.createChooser(shareIntent, sharePanelTitle /* dialog subject optional */); if (mRegistrar.activity() != null) { + List resInfoList = mRegistrar.activity().getPackageManager().queryIntentActivities(chooserIntent, PackageManager.MATCH_DEFAULT_ONLY); + for (ResolveInfo resolveInfo : resInfoList) { + String packageName = resolveInfo.activityInfo.packageName; + mRegistrar.activity().grantUriPermission(packageName, uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); + } mRegistrar.activity().startActivity(chooserIntent); } else { chooserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);