Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT,"This is a text");
startActivity(Intent.createChooser(intent,"Share"));
String path = Environment.getExternalStorageDirectory() + File.separator;//sd根目录
File file = new File(path, "test" + ".png");//这里test.png是sd卡根目录下的一个图片文件
Uri imageUri = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(intent, "Share"));
String path = Environment.getExternalStorageDirectory() + File.separator;//sd根目录
File file = new File(path, "test" + ".mp4");
Uri audioUri = Uri.fromFile(file);
ComponentName comp = new ComponentName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.JumpActivity");
Intent shareIntent = new Intent();
shareIntent.setComponent(comp);
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, audioUri);
shareIntent.setType("audio/*");
startActivity(Intent.createChooser(shareIntent, "分享视频"));
String path = Environment.getExternalStorageDirectory() + File.separator;//sd根目录
ArrayList imageUris = new ArrayList<>();
File file = new File(path, "test" + ".png");
File file2 = new File(path, "test2" + ".png");
Uri imageUri = Uri.fromFile(file);
Uri imageUri2 = Uri.fromFile(file2);
imageUris.add(imageUri);
imageUris.add(imageUri2);
Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
intent.setType("image/*");
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,imageUris);
startActivity(Intent.createChooser(intent, "Share"));
ComponentName comp = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareImgUI");
Intent shareIntent = new Intent();
shareIntent.setComponent(comp);
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "分享多张图片"));
ComponentName comp = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareToTimeLineUI");
Intent shareIntent = new Intent();
shareIntent.setComponent(comp);
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "分享多张图片"));
ComponentName comp = new ComponentName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.JumpActivity");
Intent shareIntent = new Intent();
shareIntent.setComponent(comp);
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "分享多张图片"));
String path = Environment.getExternalStorageDirectory() + File.separator;//sd根目录
File file = new File(path, "test" + ".mp4");
Uri audioUri = Uri.fromFile(file);
ComponentName comp = new ComponentName("com.qzone", "com.qzonex.module.maxvideo.activity.QzonePublishVideoActivity");
Intent shareIntent = new Intent();
shareIntent.setComponent(comp);
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, audioUri);
shareIntent.setType("video/*");
startActivity(Intent.createChooser(shareIntent, "分享视频"));
只要获得包名和相应Activity即可,方法可以查看以下文章
戳这里查看