Vihaan Verma
Vihaan Verma

Reputation: 13143

Universal image loader share images with other apps

I am using Universal Image Loader to show images in my app. There is image sharing functionality to share images with other apps.

Right now I'm doing:

ImageLoader imageLoader = ImageLoader.getInstance();
File file = imageLoader.getDiskCache().get(url);
if (file != null) {
   Util.shareImage(getActivity(), file);
}

public static void shareImage(Context context, File pictureFile) {
    Uri imageUri = Uri.parse(pictureFile.getAbsolutePath());
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
    //shareIntent.setType("image/jpeg");
    shareIntent.setType("image/*");
    context.startActivity(Intent.createChooser(shareIntent, "Share"));
}

Below are the values for variables.

enter image description here

Not sure why it's not working?

Upvotes: 1

Views: 297

Answers (2)

Vihaan Verma
Vihaan Verma

Reputation: 13143

I was missing this permission which seems to be required to be able to share images

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Upvotes: 0

parad0X parad0x
parad0X parad0x

Reputation: 29

try "static" give away

public void shareImage(Context context, File pictureFile) {
 Uri imageUri = Uri.parse(pictureFile.getAbsolutePath());
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
}

Upvotes: 0

Related Questions