I am trying to share an image through implicit intent. The image is shared successfully through Messenger and Twitter but fails on Facebook News Feed, Viber and Email. I read somewhere that I need to save the image to the external or internal SD card first before sharing. I am a little lost on 1) how to save the image to the SD card and 2) how to point to the new image location on the SD card in order to share it. Currently my code for sharing the image looks like this:
Button share = findViewById(R.id.sharetoapps);
share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Uri uri = Uri.parse("android.resource://com.testing.mypic/drawable/bad_day");
intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM,uri);
intent.setType("image/png");
startActivity(Intent.createChooser(intent, "share to:"));
}
});
And my xml is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/sharetoapps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="share" />
</LinearLayout>
If you have any pointers or know of any relevant tutorials I would appreciate it.