Divide intent in Android not to split image to any app (after popup)

I am trying to share image using sharing intent in Android. This shows the list of installed applications after clicking the button. But I choose any application that it doesn't use. An open application crashed or some application reported that sending this content type is not supported

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 give permission to read and write external storage.

Log code:

I was getting this error repeatedly:

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

      

+3


source to share


1 answer


Try the following:

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

+1


source







All Articles