Armand Baglin
Newbie
Hello,
I'm trying to send an image (Uri using FIleProvider) to messenger whithin my app. My onClickListener works very fine but when arriving to the messenger layout, it says in a dialog that "Messenger couldn't handle this file". My image is in my drawable file in my android project.
This is how I'm creating my intent, image Uri and my intent :
Here is my provider declaration in my manifest :
and my filepaths.xml :
I think there is a problem when creating my File object or when creatin my Uri file but I don't know what I'm doing wrong...
Thx !
I'm trying to send an image (Uri using FIleProvider) to messenger whithin my app. My onClickListener works very fine but when arriving to the messenger layout, it says in a dialog that "Messenger couldn't handle this file". My image is in my drawable file in my android project.
This is how I'm creating my intent, image Uri and my intent :
Code:
File imagePath = new File(getApplicationContext().getFilesDir(), "drawable-hdpi");
File f = new File(imagePath, "messenger_blue.jpg");
//File f = new File(Environment.getExternalStorageDirectory()+ File.separator + "messenger_blue.jpg");
Context context = getApplicationContext();
Uri uri = FileProvider.getUriForFile(context, "com.guivers.app.guivers.fileprovider", f);
Log.e("Message", "Uri = "+uri);
Intent sendIntent = new Intent();
sendIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
sendIntent.setType("image/jpg");
sendIntent.setPackage("com.facebook.orca");
startActivity(sendIntent);
Here is my provider declaration in my manifest :
Code:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.guivers.app.guivers.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths"/>
</provider>
and my filepaths.xml :
Code:
<paths>
<external-path name="external_files" path="."/>
</paths>
I think there is a problem when creating my File object or when creatin my Uri file but I don't know what I'm doing wrong...
Thx !