Unable to sharing image file with other app using FileProvider

448 views Asked by At

I have image list and I want to share image that selected.To do, I have used FileProvider. I'm running app on Android 10. Also I have tried without shareIntent(Intent.EXTRA_STREAM,uri), then app opening only share via dialogs.After not sharing anything just returning the app.

in AndroidManifest.xml;

<provider
        android:name="androidx.core.content.FileProvider"
        android:authorities="${applicationId}.provider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_provider_paths" />
    </provider>

in paths;

<paths>
<files-path
    name="files"
    path="/" />
<cache-path
    name="cache"
    path="/" />

here is the how I used and start intent,

 int pos = getAdapterPosition();

 File imageFile = new File(imageQuotes.get(pos).getPath());
 Uri uri = FileProvider.getUriForFile(mContext, BuildConfig.APPLICATION_ID + ".provider", imageFile);

 Intent shareIntent = new Intent(Intent.ACTION_SEND);
 shareIntent.setDataAndType(uri,"image/*");
 shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
 shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
 mContext.startActivity(shareIntent);

When run the app,after I have choosed WhatsApp for ie. My image file sent as a BIN file and not has image preview on whatsapp. uri is not null and is content://com.scoto.partestestapplication.provider/files/SavedImageQuotes/Partes_1601815401590

0

There are 0 answers