80,351
社区成员
发帖
与我相关
我的任务
分享
//分享文字
public void shareText() {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, "This is my Share text.");
shareIntent.setType("text/*");
startActivity(Intent.createChooser(shareIntent, "分享到"));
}
//分享单张图片
public void shareSingleImage() {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("http://192.168.1.101/test/nky.jpg"));
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "分享到"));
}
//分享多张图片
public void shareMultipleImage() {
ArrayList<Uri> uriList = new ArrayList<Uri>();
uriList.add(Uri.parse("http://192.168.1.101/test/nky.jpg"));
uriList.add(Uri.parse("http://192.168.1.101/test/nky.jpg"));
uriList.add(Uri.parse("http://192.168.1.101/test/nky.jpg"));
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uriList);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "分享到"));
}