By searching on the Web I see that there is more than one way to share my App by inviting others to download it.
I tried this code that works, showing up to the user the app chooser pane.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "My subject");
intent.putExtra(Intent.EXTRA_TITLE, "My subject");
intent.putExtra(Intent.EXTRA_TEXT, "https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID);
startActivity(Intent.createChooser(intent, "Share App"));
What information must I include in the Intent in order to correctly display the message when the user chooses to share it with WhatsApp, Telegram, SMS, email, etc.?
For example, this code will show a preview in Telegram (with the highlighted link and a preview image) but not in WhatsApp (it show only the plain text to send as a message): why?
I tried also this code but it works for telegram but not for Whatsapp (it send a message with only an attachment unable to open with text "without title"):
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TITLE, "title test");
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "subject test");
String shareMessage= "message test\n\n";
shareMessage = shareMessage + "https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID +"\n\n";
shareIntent.putExtra(Intent.EXTRA_TEXT, shareMessage);
shareIntent.putExtra(Intent.EXTRA_HTML_TEXT, "HTML " + shareMessage);
Uri imageUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"
+ res.getResourcePackageName(R.drawable.testjpg) + '/'
+ res.getResourceTypeName(R.drawable.testjpg) + '/'
+ res.getResourceEntryName(R.drawable.testjpg));
Toast.makeText(this, imageUri.toString(), Toast.LENGTH_LONG).show();
shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
shareIntent.setType("image/jpg");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
How to make it works for WhatsApp, Telegram, FB, Email and other text-only like SMS?