Reputation: 3
Share in Navigation bar all worked perfect but in WhatsApp it's only display link not text.
All other apps worked perfect telegram,mail etc... But in WhatsApp it's only display link not upper text.
try {
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
final String appPackageName = getApplicationContext().getPackageName();
String strAppLink = "https://play.google.com/store/apps/details?id=" + appPackageName;
shareIntent.setType("text/plain");
String shareBody = strAppLink;
String shareSub = "Hey Download this App Called\n Appname ........\nAt least One Time Try This\n";
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, shareSub);
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(shareIntent, "Share using"));
}
catch (ActivityNotFoundException e)
{
}
Upvotes: 0
Views: 69
Reputation: 409
Try this
In java:
try {
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
final String appPackageName = getApplicationContext().getPackageName();
String strAppLink = "https://play.google.com/store/apps/details?id=" + appPackageName;
shareIntent.setType("text/plain");
String shareBody = strAppLink;
String shareSub = "Hey Download this App Called\n Appname ........\nAt least One Time Try This\n";
String data = shareSub + shareBody
// shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, shareSub);
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, data);
startActivity(Intent.createChooser(shareIntent, "Share using"));
} catch (ActivityNotFoundException e) {
}
In kotlin:
try {
val shareIntent = Intent(android.content.Intent.ACTION_SEND)
val appPackageName = applicationContext.packageName
val strAppLink = "https://play.google.com/store/apps/details?id=$appPackageName"
shareIntent.type = "text/plain"
val shareSub = "Hey Download this App Called\n Appname ........\nAt least One Time Try This\n"
val data = shareSub + strAppLink
//shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, shareSub)
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, data)
startActivity(Intent.createChooser(shareIntent, "Share using"))
} catch (e: ActivityNotFoundException) {
}
There is only one change to make is comment the line which sets the subject. Merge the subject text with text and set that merged text in android.content.Intent.EXTRA_TEXT.
It works.
Upvotes: 1