1,调用分享功能
//分享文本内容
public static void shareText(Context context,String text) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT,text);
sendIntent.setType("text/plain");
context.startActivity(Intent.createChooser(sendIntent, "分享文本"));
}
//分享图片
public static void shareText(Context context,Uri uriToImage) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uriToImage);
shareIntent.setType("image/jpeg");
context.startActivity(Intent.createChooser(shareIntent, "分享图片"));
}
//分享多张图片
public static void shareText(Context context,ArrayList<Uri> imageUris) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "分享图片"));
}