MertcanDinler / Flutter-Advanced-Share

Flutter plugin for sharing
MIT License
32 stars 23 forks source link

Share image not work. #9

Open MistryHiral opened 5 years ago

MistryHiral commented 5 years ago

only first time share, the app is launched. When I try the second time, I am getting an error (in WahtsApp share ) 'this file format not support'. And i am using AdvancedShare.generic() method

E/DatabaseUtils(19589): java.lang.SecurityException: Permission Denial: reading android.support.v4.content.FileProvider uri content://com.example.wordguess.adv_provider/cache_files/1548324566.png from pid=27166, uid=10202 requires the provider be exported, or grantUriPermission()
E/DatabaseUtils(19589):     at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:646)
E/DatabaseUtils(19589):     at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:493)
E/DatabaseUtils(19589):     at android.content.ContentProvider$Transport.enforceFilePermission(ContentProvider.java:484)
E/DatabaseUtils(19589):     at android.content.ContentProvider$Transport.openTypedAssetFile(ContentProvider.java:429)
E/DatabaseUtils(19589):     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:313)
E/DatabaseUtils(19589):     at android.os.Binder.execTransact(Binder.java:453)
turanmahmudov commented 5 years ago

this also affects me

jawand commented 5 years ago

seems like this repo is dead 😞

turanmahmudov commented 5 years ago

@MistryHiral @jawand I fixed the issue with this way. In "android/src/main/java/in/mertcan/advancedshare/shareintents/Base.java" change this:

if (checkKey("url")) {
...
} 

to

if (checkKey("url")) {
            if (fileHelper.isFile()) {
                List<ResolveInfo> resInfoList = registrar.context().getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
                for (ResolveInfo resolveInfo : resInfoList) {
                    String packageName = resolveInfo.activityInfo.packageName;
                    registrar.context().grantUriPermission(packageName, fileHelper.getUri(), Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
                }

                intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                intent.putExtra(Intent.EXTRA_STREAM, fileHelper.getUri());
                intent.setType(fileHelper.getType());
            }
        }