Many times we need to share a link or other information with our friends or other users. It can be the case when we want to share our application link with other users.
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
Next we need to set the content-type so that the system can chose the application that can handle this content-type, in our case we need text/plain.
It’s time we set the body of our message and the subject if the application supports it:
sharingIntent.putExtra(Intent.EXTRA_TEXT, "Here the body");
Please notice that in case the user choses for example SMS or Twitter the body shouldn’t be more than 140 chars. For example if you want to send a link you should use a shorten link service. and the subject (if supoorted)
sharingIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject here");
Now we simply need to launch our action
startActivity(Intent.createChooser(sharingIntent, "How do you want to share?"));
The result is shown below:
var relatedpoststitle=”Related Posts :”;