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"));
  }
Samad
  • 1,776
  • 2
  • 20
  • 35

1 Answers1

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.."));
SMR
  • 6,628
  • 2
  • 35
  • 56
  • I think the case matters in mime type – SMR Feb 13 '14 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 '14 at 12:32