Suresh
Suresh

Reputation: 731

Share intent in Android not sharing image to any app (after popup)

I am trying to share image by using share intent in Android. That showing list of installed apps after button click. But I select any one app it's not sharing. The opening app crashed or some app told sending this content type not support

My code:

Intent share = new Intent(Intent.ACTION_SEND);
            File filepath = Environment.getExternalStorageDirectory();
            File dir = new File(filepath.getAbsolutePath() + "/");
            dir.mkdirs();
            Uri uri = Uri.parse(dir+"/img.jpg");
            share.putExtra(Intent.EXTRA_STREAM,uri);
            share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            share.setType("image/jpg"); 
            startActivity(Intent.createChooser(share, "Share Image"));

and also I am giving permission for read and write external storage.

Log Cat:

I got this error repeatedly:

07-06 12:25:11.654: E/SurfaceFlinger(113): SurfaceFlinger translucent=1 isOpaque=0 isExternalDisplayLayer=0 isExternalBlockLayer0

Upvotes: 3

Views: 1162

Answers (1)

Chaudhary Amar
Chaudhary Amar

Reputation: 856

Try This:

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/jpg");
Uri uri = Uri.fromFile(new File(getFilesDir(), "foo.jpg"));
shareIntent.putExtra(Intent.EXTRA_STREAM, uri.toString());
startActivity(Intent.createChooser(shareIntent, "Share image using"));

http://developer.android.com/training/sharing/send.html

Upvotes: 1

Related Questions