Question

I have my full screen activity:

    public class FullImageActivity extends Activity {



    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.full_image);

        // get intent data
        Intent i = getIntent();

        // Selected image id
        int position = i.getExtras().getInt("id");
        ImageAdapter imageAdapter = new ImageAdapter(this);

        ImageView imageView = (ImageView) findViewById(R.id.full_image_view);
        imageView.setImageResource(imageAdapter.mThumbIds[position]);
        BitmapDrawable bm = (BitmapDrawable) imageView.getDrawable();
        Bitmap mysharebmp = bm.getBitmap();


        try {
            ByteArrayOutputStream bytes = new ByteArrayOutputStream();
            mysharebmp.compress(Bitmap.CompressFormat.JPEG, 100, bytes);

            //you can create a new file name "test.jpeg"
            File f = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
                                    + File.separator + "test.jpeg");

            f.createNewFile();
            //write the bytes in file
            FileOutputStream fo = new FileOutputStream(f);
            fo.write(bytes.toByteArray());

            // remember close de FileOutput
            fo.close();
          Log.d("done","done");
        } catch (FileNotFoundException e) {
          e.printStackTrace();
        } catch (IOException e) {
          e.printStackTrace();
        }


        String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + File.separator + "test.jpeg";
        Uri m = Uri.parse(path);
        Intent sharingIntent = new Intent(Intent.ACTION_SEND);  
        sharingIntent.setType("image/*");
        sharingIntent.putExtra(Intent.EXTRA_STREAM, m);
        startActivity(Intent.createChooser(sharingIntent,
                            "Share image using"));


    }


}

Why is whatsapp the only app what is working? All other apps are telling that they are failed or unable to download.... I would like to share with every app and i don´t know what i´m doing wrong plz help me i bet it´s easy for you.

Thx dudes!

Was it helpful?

Solution

Closed Found the solution

sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/Pictures/tmp.jpeg"));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top