Trouble sharing Images

时间:2016-04-07 10:32:48

标签: java android android-image

I've been dealing with a problem regarding the sharing of images in an Android app. I've been told it's easier to save the image I want to share in the content provider. I've done that like this: ( don't know if i am doing it right )

 File auxFile = new File(getContext().getFilesDir(), imgName);
                if (!auxFile.exists()){
                    FileOutputStream fos = new FileOutputStream(auxFile);
                    fos.write(bytesDecrypted);
                    fos.flush();
                    fos.close();
                }

Once that is done I try to share the image through a chooser intent like this:

Intent shareIntent = new Intent();
                shareIntent.setAction(Intent.ACTION_SEND);
                shareIntent.setType("image/jpeg");
                Log.v("CachedProvider",CachedFileProvider.AUTHORITY);
                shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + CachedFileProvider.AUTHORITY + File.separator + imgName));
                shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                startActivity(Intent.createChooser(shareIntent,"share"));

In the app I have implemented a method that can receive Images from other apps sharing it ( that part actually work ) so I decided to test my sharing "button" with my own app but it actually don't work.

For the moment I have not set any special provider on my manifest as I don't know if that is necessary.

If further information is needed please feel free to ask.

Thanks you all very much in advance!

Edit:

When I click the "button" a "chooser" between the diferent apps that accept images is beeing displayed. Once I choose the app that I want to share the image with I get no responce.

0 个答案:

没有答案