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:SecondActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);
    TextView textView = (TextView) findViewById(R.id.textViewText);
    if (getIntent() != null && getIntent().hasExtra(Intent.EXTRA_TEXT)) {
        textView.setText(getIntent().getStringExtra(Intent.EXTRA_TEXT));
    }/*from   www .  j a  va  2s .c o m*/
}

From source file:Main.java

/**
 * Lancia la finestra per la selezione di un gestore per la condivisione di un messaggio
 * (twitter, facebook, ....).//from   w  w w  .j  a  va 2s.c  o  m
 * 
 * @param context
 * @param dialogTitle - Titolo della finestra di dialog (Share...)
 * @param subject - Subject (della email o titolo di twitter)
 * @param text - Testo del messaggio
 */
public static void share(Context context, String dialogTitle, 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);
    context.startActivity(Intent.createChooser(intent, dialogTitle));
}

From source file:com.manning.androidhacks.hack004.util.LaunchEmailUtil.java

public static void launchEmailToIntent(Context context) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "feed@back.com" });
    intent.putExtra(Intent.EXTRA_SUBJECT, "[50AH] Feedback");
    intent.putExtra(Intent.EXTRA_TEXT, "Feedback:\n");
    context.startActivity(Intent.createChooser(intent, "Send feedback"));
}

From source file:com.contentecontent.cordova.plugins.share.Share.java

private void doSendIntent(String subject, String text, String imagePath, String mimeType) {
    Uri parsedUri = Uri.parse(imagePath);
    Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
    sendIntent.setType(mimeType);//from ww w .  j  a v a 2  s.  c  o  m
    sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, text);
    sendIntent.putExtra(android.content.Intent.EXTRA_STREAM, parsedUri);
    this.cordova.startActivityForResult(this, sendIntent, 0);
}

From source file:MainActivity.java

public void onClickSwitchActivity(View view) {
    EditText editText = (EditText) findViewById(R.id.editTextData);
    String text = editText.getText().toString();
    Intent intent = new Intent(this, SecondActivity.class);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    startActivityForResult(intent, 1);//from www. j ava  2 s  .  c om
}

From source file:com.manning.androidhacks.hack036.util.LaunchEmailUtil.java

public static void launchEmailToIntent(Context context) {
    Intent msg = new Intent(Intent.ACTION_SEND);

    StringBuilder body = new StringBuilder("\n\n----------\n");
    body.append(EnvironmentInfoUtil.getApplicationInfo(context));

    msg.putExtra(Intent.EXTRA_EMAIL, context.getString(R.string.mail_support_feedback_to).split(", "));
    msg.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.mail_support_feedback_subject));
    msg.putExtra(Intent.EXTRA_TEXT, body.toString());

    msg.setType("message/rfc822");
    context.startActivity(Intent.createChooser(msg, context.getString(R.string.pref_sendemail_title)));
}

From source file:com.commonsware.android.tte.DocumentStorageService.java

public static void saveDocument(Context ctxt, Uri document, String text, boolean isClosing) {
    Intent i = new Intent(ctxt, DocumentStorageService.class).setAction(Intent.ACTION_EDIT).setData(document)
            .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
            .putExtra(Intent.EXTRA_TEXT, text).putExtra(EXTRA_CLOSING, isClosing);

    ctxt.startService(i);//from   w  w  w.j  a v a2 s . c o m
}

From source file:Main.java

/**
 * Intent chooser is customized to remove unwanted apps.
 * 1. FaceBook has bug where only links can be shared.
 * 2. Cannot share this type of content via Google Docs and Skype.
 *///from  w  w w . ja va 2 s.  co  m
public static void ShareResult(Context mContext, String mResult, String mTitle) {
    List<Intent> targetedShareIntents = new ArrayList<Intent>();
    Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    List<ResolveInfo> resInfo = mContext.getPackageManager().queryIntentActivities(shareIntent, 0);
    if (!resInfo.isEmpty()) {
        for (ResolveInfo resolveInfo : resInfo) {
            String packageName = resolveInfo.activityInfo.packageName;
            Intent targetedShareIntent = new Intent(android.content.Intent.ACTION_SEND);
            targetedShareIntent.setType("text/plain");
            targetedShareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mTitle);
            targetedShareIntent.putExtra(android.content.Intent.EXTRA_TITLE, mTitle);
            targetedShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, mResult);
            if (!packageName.toLowerCase().contains("com.facebook.katana")
                    && !packageName.toLowerCase().contains("com.google.android.apps.docs")
                    && !packageName.toLowerCase().contains("com.skype.raider")) {
                targetedShareIntent.setPackage(packageName);
                targetedShareIntents.add(targetedShareIntent);
            }
        }
        Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Send your result");
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[] {}));
        mContext.startActivity(chooserIntent);
    }
    return;
}

From source file:com.phunkosis.gifstitch.helpers.ShareHelper.java

public static void startShareLinkIntent(Activity activity, String url) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_TEXT, activity.getResources().getString(R.string.share_link_body) + " " + url);
    intent.putExtra(Intent.EXTRA_SUBJECT, activity.getResources().getString(R.string.share_link_subject));
    intent.setType("text/plain");
    activity.startActivity(Intent.createChooser(intent, "Share "));
}

From source file:ca.rmen.android.scrumchatter.export.Export.java

/**
 * Bring up the chooser to send the file.
 *///from www . j  a  v a2 s.  c o m
static void share(Context context, File file, String mimeType) {
    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.export_message_subject));
    sendIntent.putExtra(Intent.EXTRA_TEXT, context.getString(R.string.export_message_body));
    Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileprovider", file);
    sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
    sendIntent.setType(mimeType);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
        List<ResolveInfo> resInfoList = context.getPackageManager().queryIntentActivities(sendIntent,
                PackageManager.MATCH_DEFAULT_ONLY);
        for (ResolveInfo resolveInfo : resInfoList) {
            String packageName = resolveInfo.activityInfo.packageName;
            context.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
            Log.v(TAG, "grant permission to " + packageName);
        }
    }
    context.startActivity(
            Intent.createChooser(sendIntent, context.getResources().getText(R.string.action_share)));
}