Thursday, February 8, 2018

How to share Text in Android

In Android, we can share a text, image anr many thing things.

In the post we will learn how to share text in Android.

To do this we need an Object of class Intent and set action " android.intent.action.SEND"


Code:


Intent localIntent = new Intent();
   
    localIntent.setAction("android.intent.action.SEND");
    localIntent.putExtra("android.intent.extra.TEXT", "Text To Share");
    localIntent.setType("text/plain");
    startActivity(Intent.createChooser(localIntent, "Share..."));


It will open a chooser doalog with many options like SMS, Whatsapp, Mail, facebook etc,  in which user can select any option.

No comments:

Post a Comment