//分享文字 Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, "要分享的文本。"); intent.setType("text/plain"); startActivity(Intent.createChooser(intent, "分享"));
//分享图片 Uri uri = Uri.fromFile(new File("/storage/emulated/0/DCIM/Camera/img.jpg")); Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_STREAM, uri); intent.setType("image/jpeg"); startActivity(Intent.createChooser(intent, "分享"));
//分享一系列图片 ArrayList<Uri> uris = new ArrayList<>(); uris.add(Uri.fromFile(new File("/storage/emulated/0/DCIM/Camera/img.jpg"))); uris.add(Uri.fromFile(new File("/storage/emulated/0/DCIM/Camera/aaa.jpeg"))); Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); intent.setType("image/*"); startActivity(Intent.createChooser(intent, "分享"));
原文地址:http://blog.csdn.net/qiantujava/article/details/44195031