share Text via Intent - Android android.content

Android examples for android.content:Intent

Description

share Text via Intent

Demo Code

import android.content.Context;
import android.content.Intent;

public class Main {

  public static void shareText(Context ctx, String title, String text) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    // intent.putExtra(Intent.EXTRA_SUBJECT, title);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    ctx.startActivity(Intent.createChooser(intent, title));

  }//from   ww w  . j  a  va  2  s  .  c  om

}

Related Tutorials