3

I have activity with image view and share button, the image retrieved from DB

I want to save the image at first then share it

every things is going fine , the image saved in internal memory and it's going to share but when the other app runs (like whatsapp or messaging) it says file not support

I have push other image to ddms manually and then share is works without any problem !! O.o

I think the problem is from saving the bitmap, even I checked the saved bitmap from the ddms and it was looks good

there is my codes:

save

  try {
        FileOutputStream out = new FileOutputStream(new File(getFilesDir(), "temp.png"));
        imageview.setImageBitmap(b1);
        b1.compress(Bitmap.CompressFormat.PNG, 100, out);
        out.flush();
        out.close();
       }
       catch (Exception e) {}

share method

  private void initShareIntent(String type,String _text)
  {
        Intent shareIntent = new Intent();
        shareIntent.setAction(Intent.ACTION_SEND);
        shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File(getFilesDir(), "temp.png")));
        shareIntent.setType("image/PNG");
        shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        startActivity(Intent.createChooser(shareIntent, "send"));
  }
2

1 Answer 1

0

Edit this

shareIntent.setType("image/*");

To this

shareIntent.setType("image/png");

I think it should work. Let me know if it works for you!!

[EDIT1] changed to png (instead of PNG) cause I think the case matters here. lol

[EDIT2] for multiple images try this (provided by GOOGLE :P)

ArrayList<Uri> imageUris = new ArrayList<Uri>();
imageUris.add(imageUri1); // Add your image URIs here
imageUris.add(imageUri2);

Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "Share images to.."));
2
  • I think the case matters in mime type
    – SMR
    Feb 13, 2014 at 12:04
  • no the problem not from here i have checked every thing before as I sad it's save the bitmap but it's not sharing but if i change the bitmap manually it's work :|
    – Samad
    Feb 13, 2014 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.