Reputation: 3585
I am working on text sharing in all default available app like,facebook,gmail..etc.
Here I put snapshot of my code.
final Intent emailIntent1 = new Intent(
android.content.Intent.ACTION_SEND);
emailIntent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent1.setAction("https://play.google.com/store");
emailIntent1.putExtra(Intent.EXTRA_TEXT,"https://play.google.com/store");
emailIntent1.setType("image/png");
startActivity(Intent.createChooser(emailIntent1, "send"));
My problem is ,I can not share text in facebook.
Your answer would be appreciated.
Upvotes: 1
Views: 2596
Reputation: 508
Try this code. It will create an Intent Chooser that list out all the installed app on the device that accept type "text/plain".
private void share(String text) {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(shareIntent, "Share text"));
}
Upvotes: 0
Reputation: 2623
Try this...
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Share this app");
String shareMessage = "https://play.google.com/store";
shareIntent.putExtra(Intent.EXTRA_TEXT, shareMessage);
startActivity(Intent.createChooser(shareIntent, "Choose the messenger to share this App"));
Upvotes: 2