Android is built-in sharing function, but also has certain limitation, can share pictures, text, video, audio, etc., can also share photos, but does not support direct share a card (including graphic, links), and so are generally will need to share the content of the added to the image, or through a whole bunch of words to share.

Below is the specific code of several sharing methods:

Set action to send or Send multiple, and set the type of sharing and the content to be shared

Share the words

Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); Intent.putextra (Intent.extra_text, "text "); intent.setType("text/plain"); startActivity(intent);Copy the code

Share photos

private void shareImage(Bitmap bitmap) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SEND);
    Uri uri = Uri.parse(MediaStore.Images.Media.insertImage(mActivity.getContentResolver(), bitmap, "IMG" + Calendar.getInstance().getTime(), null));
    intent.setType("image/*");
    intent.putExtra(Intent.EXTRA_STREAM, uri);
    mActivity.startActivity(Intent.createChooser(intent, "title"));
}
Copy the code

Share the photos

ArrayList<Uri> imageUris = new ArrayList<>();
imageUris.add(uri);
imageUris.add(uri);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "dlgTitle"));
Copy the code

Share to the specified platform

Intent wechatIntent = new Intent(Intent.ACTION_SEND); wechatIntent.setPackage("com.tencent.mm"); wechatIntent.setType("text/plain"); Wechatintent.putextra (Intent.extra_text, "Shared content in wechat "); startActivity(wechatIntent);Copy the code

Here are the types of sharing supported:

text/plain
application/*
image/*
video/*
audio/*
Copy the code

I hope I can help friends with relevant needs