Create Select 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 Select 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
Submit multiple pieces of content
To share multiple pieces of content, use the ACTION_SEND_MULTIPLE action along with a list of URIs that point to the content. The type of MIME depends on the type of content you are sharing. For example, if you transfer 3 images in JPEG format, the type is still "image/jpeg" . For a mixture of image types, this should be "image/*" to match the activity that processes any type of image. You should use the "*/*" case if you are using different types. As stated earlier, this is before receiving an application to analyze and process your data. Here is 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 Email
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(); }