List of usage examples for android.content Intent EXTRA_TEXT
String EXTRA_TEXT
To view the source code for android.content Intent EXTRA_TEXT.
Click Source Link
From source file:Main.java
public static Intent share(String text, String mimeType, Uri... attachments) { final Intent intent = new Intent(); intent.setType(mimeType);// w w w . ja v a2 s .c o m if (attachments.length > 1) { intent.setAction(Intent.ACTION_SEND_MULTIPLE); final ArrayList<CharSequence> textExtra = new ArrayList<>(); textExtra.add(text); intent.putCharSequenceArrayListExtra(Intent.EXTRA_TEXT, textExtra); final ArrayList<Parcelable> uris = new ArrayList<>(); Collections.addAll(uris, attachments); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); } else { intent.setAction(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, text); intent.putExtra(Intent.EXTRA_STREAM, attachments[0]); } return intent; }
From source file:Main.java
@SuppressLint("InlinedApi") public static void launchPlainText(Context context, String text, CharSequence chooserTitle) { // See http://android-developers.blogspot.com/2012/02/share-with-intents.html Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); intent.putExtra(Intent.EXTRA_TEXT, text); // intent.putExtra( Intent.EXTRA_SUBJECT, subject ); // intent.putExtra( Intent.EXTRA_EMAIL, new String[] { emailTo } ); context.startActivity(Intent.createChooser(intent, chooserTitle)); }
From source file:Main.java
public static void share(Context pContext, String urlToShare, String titleChosser, String subject) { Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, urlToShare); intent.setType("text/plain"); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); pContext.startActivity(Intent.createChooser(intent, titleChosser)); }
From source file:Main.java
public static void sendEmail(Context ctx, String[] emailAddresses, String[] CCAddresses, String subject, String message) {//from w ww.j a v a 2 s . c o m Intent emailIntent = new Intent(Intent.ACTION_SEND); // emailIntent.setType("text/plain"); emailIntent.setData(Uri.parse("mailto:")); String[] to = emailAddresses; String[] cc = CCAddresses; emailIntent.putExtra(Intent.EXTRA_EMAIL, to); if (CCAddresses != null) { emailIntent.putExtra(Intent.EXTRA_CC, cc); } emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(Intent.EXTRA_TEXT, message); emailIntent.setType("message/rfc822"); ctx.startActivity(Intent.createChooser(emailIntent, "Email")); }
From source file:Main.java
/** * Share the crisis with your friend and/or the world. *//* w w w.jav a 2 s . c o m*/ public static Intent shareCrisis(String crisisID, String shortTitle) { Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("text/plain"); StringBuffer shareContent = new StringBuffer(); shareContent.append(shortTitle); shareContent.append(" - "); shareContent.append("http://www.sigimera.org/crises/"); shareContent.append(crisisID); shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareContent.toString()); return shareIntent; }
From source file:Main.java
/** * send a message to call the emergency with location of the accident * * @param latitude//w w w .j a va 2 s .c o m * @param longitude */ public static void sendEmergencyToMessages(double latitude, double longitude, Context context) { Intent sendSmsIntent = new Intent(Intent.ACTION_VIEW); sendSmsIntent.setData(Uri.parse("sms:")); sendSmsIntent.setType("vnd.android-dir/mms-sms"); String message = "The Car had accident at: " + latitude + " , " + longitude; sendSmsIntent.putExtra(Intent.EXTRA_TEXT, message); if (sendSmsIntent.resolveActivity(context.getPackageManager()) != null) { context.startActivity(sendSmsIntent); } }
From source file:Main.java
/** * Send an email via available mail activity * // ww w . j a va2 s .c o m * @param context the app context * @param to the email address send to * @param subject the email subject * @param body the email body * @param attachments the uris for attachments */ public static void sendEmail(Context context, String to, String subject, String body, Uri... attachments) { Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE); emailIntent.setType("plain/text"); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(Intent.EXTRA_TEXT, body); if (attachments != null && attachments.length != 0) { ArrayList<Uri> uris = new ArrayList<Uri>(); for (int i = 0; i < attachments.length; i++) uris.add(attachments[i]); emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); } context.startActivity(Intent.createChooser(emailIntent, null)); }
From source file:Main.java
public static void sendEmail(Context context, String chooserTitle, String mailAddress, String subject, String preContent) {// w ww .j av a 2s . c o m final Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { mailAddress }); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); String content = "\n\n=====================\n"; content += "Device Environment: \n----\n" + preContent; emailIntent.putExtra(Intent.EXTRA_TEXT, content); context.startActivity(Intent.createChooser(emailIntent, chooserTitle)); }
From source file:Main.java
public static void sendText(Context context, String text) { String mimeType = getMimeTypeForExtension("txt"); Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType(mimeType);//from w ww .jav a 2 s. co m intent.putExtra(Intent.EXTRA_TEXT, text); context.startActivity(intent); }
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); textView.setText(getIntent().getStringExtra(Intent.EXTRA_TEXT)); }