-1

I'm trying to do an Intent to share an image from an SD card. But I have a problem with the share button: It says:

no app can perform this action

So, which type of code I have to use to share an image? I want, maybe, to have the possibility to send my image as an e-mail or a message. Hope someone can help me.

Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
Chicca94
  • 3
  • 4
  • post your code here as well. – Sharjeel Mar 10 '14 at 13:08
  • possible duplicate of [How to use "Share image using" sharing Intent to share images in android?](http://stackoverflow.com/questions/7661875/how-to-use-share-image-using-sharing-intent-to-share-images-in-android) – DroidDev Mar 10 '14 at 13:25
  • Here is my code. Also I will see the answer. Thanks for the message Vishwas [link](https://gist.github.com/anonymous/9465059). Press the word 'link' for the code – Chicca94 Mar 10 '14 at 13:38

2 Answers2

0

first you need to store img in storege like this way

 Bitmap icon = mBitmap;
    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("image/jpeg");
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    icon.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
    File f = new File(Environment.getExternalStorageDirectory() + File.separator + "temporary_file.jpg");
    try {
        f.createNewFile();
        FileOutputStream fo = new FileOutputStream(f);
        fo.write(bytes.toByteArray());
    } catch (IOException e) {                       
            e.printStackTrace();
    }

and then you can share it like this way

 share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/temporary_file.jpg"));
    startActivity(Intent.createChooser(share, "Share Image"));
Android
  • 8,995
  • 9
  • 67
  • 108
0

"no app can perform this action" because, there was no sharing application installed in your device. Install some third party applications like facebook, whats app, gmail... in your real device and run your application to share image.

and also start activity like below:

share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/temporary_file.jpg"));
startActivity(Intent.createChooser(share, "Share Image"));
Lokesh
  • 5,180
  • 4
  • 27
  • 42