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:com.androzic.MapActivity.java
@Override public void onWaypointShare(final Waypoint waypoint) { Intent i = new Intent(android.content.Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra(Intent.EXTRA_SUBJECT, R.string.currentloc); String coords = StringFormatter.coordinates(application.coordinateFormat, " ", waypoint.latitude, waypoint.longitude);/*ww w. j ava 2s. com*/ i.putExtra(Intent.EXTRA_TEXT, waypoint.name + " @ " + coords); startActivity(Intent.createChooser(i, getString(R.string.menu_share))); }
From source file:org.openintents.shopping.ui.ShoppingActivity.java
private void sendList() { if (mItemsView.getAdapter() instanceof CursorAdapter) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < mItemsView.getAdapter().getCount(); i++) { Cursor item = (Cursor) mItemsView.getAdapter().getItem(i); if (item.getLong(mStringItemsSTATUS) == ShoppingContract.Status.BOUGHT) { sb.append("[X] "); } else { sb.append("[ ] "); }/*from w ww . ja v a2 s. c o m*/ String quantity = item.getString(mStringItemsQUANTITY); long pricecent = item.getLong(mStringItemsITEMPRICE); String price = PriceConverter.getStringFromCentPrice(pricecent); String tags = item.getString(mStringItemsITEMTAGS); if (!TextUtils.isEmpty(quantity)) { sb.append(quantity); sb.append(" "); } String units = item.getString(mStringItemsITEMUNITS); if (!TextUtils.isEmpty(units)) { sb.append(units); sb.append(" "); } sb.append(item.getString(mStringItemsITEMNAME)); // Put additional info (price, tags) in brackets boolean p = !TextUtils.isEmpty(price); boolean t = !TextUtils.isEmpty(tags); if (p || t) { sb.append(" ("); if (p) { sb.append(price); } if (p && t) { sb.append(", "); } if (t) { sb.append(tags); } sb.append(")"); } sb.append("\n"); } Intent i = new Intent(); i.setAction(Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra(Intent.EXTRA_SUBJECT, getCurrentListName()); i.putExtra(Intent.EXTRA_TEXT, sb.toString()); try { startActivity(Intent.createChooser(i, getString(R.string.send))); } catch (ActivityNotFoundException e) { Toast.makeText(this, R.string.email_not_available, Toast.LENGTH_SHORT).show(); Log.e(TAG, "Email client not installed"); } } else { Toast.makeText(this, R.string.empty_list_not_sent, Toast.LENGTH_SHORT); } }
From source file:edu.mit.viral.shen.DroidFish.java
private final void shareGame() { Intent i = new Intent(Intent.ACTION_SEND); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); i.setType("text/plain"); i.putExtra(Intent.EXTRA_TEXT, ctrl.getPGN()); startActivity(Intent.createChooser(i, getString(R.string.share_pgn_game))); }
From source file:com.if3games.chessonline.DroidFish.java
private final void shareGame() { Intent i = new Intent(Intent.ACTION_SEND); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); i.setType("text/plain"); //i.putExtra(Intent.EXTRA_TEXT, ctrl.getPGN()); i.putExtra(Intent.EXTRA_TEXT, getString(R.string.app_name) + " " + ConstantsData.MARKET_URL_HTTP); startActivity(Intent.createChooser(i, getString(R.string.share_pgn_game))); }
From source file:com.android.mms.ui.ComposeMessageActivity.java
private boolean handleSendIntent() { Intent intent = getIntent();//w w w. ja v a 2 s .c om Bundle extras = intent.getExtras(); if (extras == null) { return false; } final String mimeType = intent.getType(); String action = intent.getAction(); if (Intent.ACTION_SEND.equals(action)) { if (extras.containsKey(Intent.EXTRA_STREAM)) { final Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM); getAsyncDialog().runAsync(new Runnable() { @Override public void run() { addAttachment(mimeType, uri, false); } }, null, R.string.adding_attachments_title); return true; } else if (extras.containsKey(Intent.EXTRA_TEXT)) { mWorkingMessage.setText(extras.getString(Intent.EXTRA_TEXT)); return true; } } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && extras.containsKey(Intent.EXTRA_STREAM)) { SlideshowModel slideShow = mWorkingMessage.getSlideshow(); final ArrayList<Parcelable> uris = extras.getParcelableArrayList(Intent.EXTRA_STREAM); int currentSlideCount = slideShow != null ? slideShow.size() : 0; int importCount = uris.size(); if (importCount + currentSlideCount > SlideshowEditor.MAX_SLIDE_NUM) { importCount = Math.min(SlideshowEditor.MAX_SLIDE_NUM - currentSlideCount, importCount); Toast.makeText(ComposeMessageActivity.this, getString(R.string.too_many_attachments, SlideshowEditor.MAX_SLIDE_NUM, importCount), Toast.LENGTH_LONG).show(); } // Attach all the pictures/videos asynchronously off of the UI thread. // Show a progress dialog if adding all the slides hasn't finished // within half a second. final int numberToImport = importCount; getAsyncDialog().runAsync(new Runnable() { @Override public void run() { for (int i = 0; i < numberToImport; i++) { Parcelable uri = uris.get(i); addAttachment(mimeType, (Uri) uri, true); } } }, null, R.string.adding_attachments_title); return true; } return false; }
From source file:org.getlantern.firetweet.util.Utils.java
public static void startStatusShareChooser(final Context context, final ParcelableStatus status) { final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); final String name = status.user_name, screenName = status.user_screen_name; final String timeString = formatToLongTimeString(context, status.timestamp); final String subject = context.getString(R.string.status_share_subject_format_with_time, name, screenName, timeString);// w w w . j ava2 s . c om intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, status.text_plain); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); context.startActivity(Intent.createChooser(intent, context.getString(R.string.share))); }
From source file:com.codename1.impl.android.AndroidImplementation.java
/** * @inheritDoc/*from w ww .ja va2s .com*/ */ public void sendMessage(String[] recipients, String subject, Message msg) { if (editInProgress()) { stopEditing(true); } Intent emailIntent; String attachment = msg.getAttachment(); boolean hasAttachment = (attachment != null && attachment.length() > 0) || msg.getAttachments().size() > 0; if (msg.getMimeType().equals(Message.MIME_TEXT) && !hasAttachment) { StringBuilder to = new StringBuilder(); for (int i = 0; i < recipients.length; i++) { to.append(recipients[i]); to.append(";"); } emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + to.toString() + "?subject=" + Uri.encode(subject) + "&body=" + Uri.encode(msg.getContent()))); } else { if (hasAttachment) { if (msg.getAttachments().size() > 1) { emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); emailIntent.setType(msg.getMimeType()); ArrayList<Uri> uris = new ArrayList<Uri>(); for (String path : msg.getAttachments().keySet()) { uris.add(Uri.parse(fixAttachmentPath(path))); } emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); } else { emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); emailIntent.setType(msg.getMimeType()); emailIntent.setType(msg.getAttachmentMimeType()); //if the attachment is in the uder home dir we need to copy it //to an accessible dir attachment = fixAttachmentPath(attachment); emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(attachment)); } } else { emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); emailIntent.setType(msg.getMimeType()); } if (msg.getMimeType().equals(Message.MIME_HTML)) { emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(msg.getContent())); } else { /* // Attempted this workaround to fix the ClassCastException that occurs on android when // there are multiple attachments. Unfortunately, this fixes the stack trace, but // has the unwanted side-effect of producing a blank message body. // Same workaround for HTML mimetype also fails the same way. // Conclusion, Just live with the stack trace. It doesn't seem to affect the // execution of the program... treat it as a warning. // See https://github.com/codenameone/CodenameOne/issues/1782 if (msg.getAttachments().size() > 1) { ArrayList<String> contentArr = new ArrayList<String>(); contentArr.add(msg.getContent()); emailIntent.putStringArrayListExtra(android.content.Intent.EXTRA_TEXT, contentArr); } else { emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, msg.getContent()); }*/ emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, msg.getContent()); } } final String attach = attachment; AndroidNativeUtil.startActivityForResult(Intent.createChooser(emailIntent, "Send mail..."), new IntentResultListener() { @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (attach != null && attach.length() > 0 && attach.contains("tmp")) { FileSystemStorage.getInstance().delete(attach); } } }); }
From source file:com.codename1.impl.android.AndroidImplementation.java
@Override public void share(String text, String image, String mimeType, Rectangle sourceRect) { /*if(!checkForPermission(Manifest.permission.READ_PHONE_STATE, "This is required to perform share")){ return;//from w w w .j a v a2 s .c o m }*/ Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); if (image == null) { shareIntent.setType("text/plain"); shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, text); } else { shareIntent.setType(mimeType); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(fixAttachmentPath(image))); shareIntent.putExtra(Intent.EXTRA_TEXT, text); } getContext().startActivity(Intent.createChooser(shareIntent, "Share with...")); }