Example usage for android.content Intent EXTRA_TEXT

List of usage examples for android.content Intent EXTRA_TEXT

Introduction

In this page you can find the example usage for android.content Intent EXTRA_TEXT.

Prototype

String EXTRA_TEXT

To view the source code for android.content Intent EXTRA_TEXT.

Click Source Link

Document

A constant CharSequence that is associated with the Intent, used with #ACTION_SEND to supply the literal data to be sent.

Usage

From source file:Main.java

static Intent makeShareIntent(String subject, String text) {
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    return intent;
}

From source file:Main.java

public static void forward(Context context, String body) {
    if (body != null) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, body);
        context.startActivity(intent);//from  w  ww  .  j  ava  2s.c  om
    }
}

From source file:Main.java

public static boolean share(Context context, String title, String content) {
    Intent send = new Intent(Intent.ACTION_SEND);
    send.setType("text/plain");
    send.putExtra(Intent.EXTRA_TEXT, content);
    send.putExtra(Intent.EXTRA_SUBJECT, title);
    try {//from  w w w.j a  v  a 2s  . com
        context.startActivity(Intent.createChooser(send, content));
    } catch (android.content.ActivityNotFoundException ex) {
        return false;
    }
    return true;
}

From source file:Main.java

public static void shareText(Context context, 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);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);// Intent.createChooser(intent, title)
}

From source file:Main.java

public static void sendMail(Context context, String email) {
    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { email });
    sendIntent.putExtra(Intent.EXTRA_TEXT, "");
    sendIntent.setType("text/plain");
    context.startActivity(sendIntent);//w  ww.  j a v a2s.  c om
}

From source file:Main.java

public static Intent newEmailIntent(String toAddress, String subject, String body, String cc) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { toAddress });
    intent.putExtra(Intent.EXTRA_TEXT, body);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_CC, cc);
    intent.setType("message/rfc822");
    return intent;
}

From source file:Main.java

public static void share(Context context, String imageFileLocation, String textToSend) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("image/*");

    intent.putExtra(Intent.EXTRA_TEXT, textToSend);
    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imageFileLocation)));

    context.startActivity(Intent.createChooser(intent, "Share with..."));
}

From source file:Main.java

public static Intent newEmailIntent(Context context, String address, String subject, String body, String cc) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { address });
    intent.putExtra(Intent.EXTRA_TEXT, body);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_CC, cc);
    intent.setType("message/rfc822");
    return intent;
}

From source file:Main.java

public static void shareViaEmail(Context context, String subject, String text) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setType("text/html");
    intent.setData(Uri.parse("mailto:"));
    intent.putExtra(Intent.EXTRA_TEXT, text);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    context.startActivity(Intent.createChooser(intent, "Share via Email"));
}

From source file:Main.java

public static void shareAppInfo(Context context, String info) {
    if (!TextUtils.isEmpty(info)) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, info);
        context.startActivity(intent);/*from w  w w  .j av  a2s.com*/
    }
}