android-intent Intent Use of Intent to Share text

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

On calling, an application chooser dialog will appear and by selecting an application you can share your content with it.

For calling use this line of code in your program class:

share(context, "This is a test message", "Test Subject")

Function's definition:

public static void share (Context context, String text, String subject, String title, String dialogHeaderText) {
    Intent intent = new Intent(android.content.Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(android.content.Intent.EXTRA_TEXT, text);
    intent.putExtra(Intent.EXTRA_TITLE, title);
    context.startActivity(Intent.createChooser(intent, dialogHeaderText));
}

See original post here: http://stackoverflow.com/a/35159850/3819836



Got any android-intent Question?