Create Choose Editable
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "My application name");
String sAux = "\nLet me recommend you this application\n\n";
sAux = sAux + "https://play.google.com/store/apps/details?id=the.package.id \n\n";
sendIntent.putExtra(Intent.EXTRA_TEXT, sAux);
startActivity(Intent.createChooser(sendIntent, "choose one"));
==============================================================
Create Choose Default
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
startActivity(sendIntent);
=================================================================
Multi-Piece send
Send multiple pieces of content
To share multiple pieces of content, use the ACTION_SEND_MULTIPLE action together with a list of URIs pointing to the content. The MIME type varies according to the mix of content you're sharing. For example, if you share 3 JPEG images, the type is still "image/jpeg"
. For a mixture of image types, it should be "image/*"
to match an activity that handles any type of image. You should only use "*/*"
if you're sharing out a wide variety of types. As previously stated, it's up to the receiving application to parse and process your data. Here's an example:
ArrayList<Uri> imageUris = new ArrayList<Uri>();
imageUris.add(imageUri1); // Add your image URIs here
imageUris.add(imageUri2);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "Share images to.."));
================================================================
Share With Facebook
ShareLinkContent shareLinkContent = new ShareLinkContent.Builder()
.setQuote("Application of social rating share with your friend")
.setContentUrl(Uri.parse("https://google.com"))
.build();
if (ShareDialog.canShow(ShareLinkContent.class)) {
sd.show(shareLinkContent);
}
==============================================================
Share With SMS
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra("Body", "Application of social rating share with your friend");
intent.setType("vnd.android-dir/mms-sms");
startActivity(intent);
==============================================================
Share With Mail
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "", null));
emailIntent.putExtra(Intent.EXTRA_EMAIL, "Address");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Application of social rating share with your friend");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Body");
startActivity(Intent.createChooser(emailIntent, "Send Email..."));
=============================================================
Share with WhatsApp
Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
whatsappIntent.setType("text/plain");
whatsappIntent.setPackage("com.whatsapp");
whatsappIntent.putExtra(Intent.EXTRA_TEXT, "Application of social rating share with your friend");
try {
Objects.requireNonNull(getActivity()).startActivity(whatsappIntent);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getActivity(), "WhatsApp have not been installed.", Toast.LENGTH_SHORT).show();
}