Android Intent share photo

Description

Android Intent share photo


import android.app.Activity;

import android.content.Intent;

import android.net.Uri;

import java.io.File;

public class Main {
    public static void main(String[] argv) throws Exception {
    }// w  w  w  .  ja  v a  2  s.c  o  m

    public static void sharePhoto(final Activity activity, String photoUri) {
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        File file = new File(photoUri);
        shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
        shareIntent.setType("image/jpeg");
        activity.startActivity(Intent.createChooser(shareIntent, activity.getTitle()));
    }
}



PreviousNext

Related