List of usage examples for android.content Intent EXTRA_SUBJECT
String EXTRA_SUBJECT
To view the source code for android.content Intent EXTRA_SUBJECT.
Click Source Link
From source file:com.juick.android.MainActivity.java
private void obtainSavedMessagesURL(final boolean reset) { final ProgressDialog pd = new ProgressDialog(MainActivity.this); pd.setIndeterminate(true);//from w ww . ja v a 2 s . co m pd.setTitle("Saved Messages"); pd.setMessage("Waiting for server key"); pd.setCancelable(true); pd.show(); new Thread("obtainSavedMessagesURL") { @Override public void run() { final RESTResponse restResponse = DatabaseService.obtainSharingURL(MainActivity.this, reset); if (restResponse.getErrorText() == null) try { new JSONObject(restResponse.getResult()); } catch (JSONException e) { restResponse.errorText = e.toString(); } runOnUiThread(new Runnable() { @Override public void run() { pd.cancel(); if (restResponse.getErrorText() != null) { Toast.makeText(MainActivity.this, restResponse.getErrorText(), Toast.LENGTH_LONG) .show(); } else { try { final String url = (String) new JSONObject(restResponse.getResult()).get("url"); if (url.length() == 0) { Toast.makeText(MainActivity.this, "You don't have key yet. Choose another option.", Toast.LENGTH_LONG) .show(); } else { new AlertDialog.Builder(MainActivity.this).setTitle("You got key!") .setMessage(url) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setNeutralButton("Share with..", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent share = new Intent( android.content.Intent.ACTION_SEND); share.setType("text/plain"); share.addFlags( Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); share.putExtra(Intent.EXTRA_SUBJECT, "My Saved messages on Juick Advanced"); share.putExtra(Intent.EXTRA_TEXT, url); startActivity( Intent.createChooser(share, "Share link")); } }) .setCancelable(true).show(); } } catch (JSONException e) { Toast.makeText(MainActivity.this, e.toString(), Toast.LENGTH_LONG).show(); } } } }); } }.start(); }
From source file:com.ichi2.anki.DeckPicker.java
public void emailFile(String path) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_SUBJECT, "AnkiDroid Apkg"); File attachment = new File(path); if (attachment.exists()) { Uri uri = Uri.fromFile(attachment); intent.putExtra(Intent.EXTRA_STREAM, uri); }//from w w w . j a v a2 s . c o m try { startActivityWithoutAnimation(intent); } catch (ActivityNotFoundException e) { Themes.showThemedToast(this, getResources().getString(R.string.no_email_client), false); } }
From source file:com.android.mail.compose.ComposeActivity.java
/** * Fill all the widgets with the content found in the Intent Extra, if any. * Also apply the same style to all widgets. Note: if initFromExtras is * called as a result of switching between reply, reply all, and forward per * the latest revision of Gmail, and the user has already made changes to * attachments on a previous incarnation of the message (as a reply, reply * all, or forward), the original attachments from the message will not be * re-instantiated. The user's changes will be respected. This follows the * web gmail interaction.//from w w w . j a v a 2 s.com * @return {@code true} if the activity should not call {@link #finishSetup}. */ public boolean initFromExtras(Intent intent) { // If we were invoked with a SENDTO intent, the value // should take precedence final Uri dataUri = intent.getData(); if (dataUri != null) { if (MAIL_TO.equals(dataUri.getScheme())) { initFromMailTo(dataUri.toString()); } else { if (!mAccount.composeIntentUri.equals(dataUri)) { String toText = dataUri.getSchemeSpecificPart(); if (toText != null) { mTo.setText(""); addToAddresses(Arrays.asList(TextUtils.split(toText, ","))); } } } } String[] extraStrings = intent.getStringArrayExtra(Intent.EXTRA_EMAIL); if (extraStrings != null) { addToAddresses(Arrays.asList(extraStrings)); } extraStrings = intent.getStringArrayExtra(Intent.EXTRA_CC); if (extraStrings != null) { addCcAddresses(Arrays.asList(extraStrings), null); } extraStrings = intent.getStringArrayExtra(Intent.EXTRA_BCC); if (extraStrings != null) { addBccAddresses(Arrays.asList(extraStrings)); } String extraString = intent.getStringExtra(Intent.EXTRA_SUBJECT); if (extraString != null) { mSubject.setText(extraString); } for (String extra : ALL_EXTRAS) { if (intent.hasExtra(extra)) { String value = intent.getStringExtra(extra); if (EXTRA_TO.equals(extra)) { addToAddresses(Arrays.asList(TextUtils.split(value, ","))); } else if (EXTRA_CC.equals(extra)) { addCcAddresses(Arrays.asList(TextUtils.split(value, ",")), null); } else if (EXTRA_BCC.equals(extra)) { addBccAddresses(Arrays.asList(TextUtils.split(value, ","))); } else if (EXTRA_SUBJECT.equals(extra)) { mSubject.setText(value); } else if (EXTRA_BODY.equals(extra)) { setBody(value, true /* with signature */); } else if (EXTRA_QUOTED_TEXT.equals(extra)) { initQuotedText(value, true /* shouldQuoteText */); } } } Bundle extras = intent.getExtras(); if (extras != null) { CharSequence text = extras.getCharSequence(Intent.EXTRA_TEXT); setBody((text != null) ? text : "", true /* with signature */); // TODO - support EXTRA_HTML_TEXT } mExtraValues = intent.getParcelableExtra(EXTRA_VALUES); if (mExtraValues != null) { LogUtils.d(LOG_TAG, "Launched with extra values: %s", mExtraValues.toString()); initExtraValues(mExtraValues); return true; } return false; }
From source file:es.javocsoft.android.lib.toolbox.ToolBox.java
/** * Allows to create a share intent and it can be launched. * //from www. j a v a 2 s . c o m * @param context * @param type Mime type. * @param nameApp You can filter the application you want to share with. Use "wha", "twitt", etc. * @param title The title of the share.Take in account that sometimes is not possible to add the title. * @param data The data, can be a file or a text. * @param isBinaryData If the share has a data file, set to TRUE otherwise FALSE. */ @SuppressLint("DefaultLocale") public static Intent share_newSharingIntent(Context context, String type, String nameApp, String title, String data, boolean isBinaryData, boolean launch) { Intent res = null; Intent share = new Intent(Intent.ACTION_SEND); share.setType(type); List<Intent> targetedShareIntents = new ArrayList<Intent>(); List<ResolveInfo> resInfo = context.getPackageManager().queryIntentActivities(share, 0); if (!resInfo.isEmpty()) { for (ResolveInfo info : resInfo) { Intent targetedShare = new Intent(Intent.ACTION_SEND); targetedShare.setType(type); if (title != null) { targetedShare.putExtra(Intent.EXTRA_SUBJECT, title); targetedShare.putExtra(Intent.EXTRA_TITLE, title); if (data != null && !isBinaryData) { targetedShare.putExtra(Intent.EXTRA_TEXT, data); } } if (data != null && isBinaryData) { targetedShare.putExtra(Intent.EXTRA_TEXT, title); targetedShare.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(data))); } if (nameApp != null) { if (info.activityInfo.packageName.toLowerCase().contains(nameApp) || info.activityInfo.name.toLowerCase().contains(nameApp)) { targetedShare.setPackage(info.activityInfo.packageName); targetedShareIntents.add(targetedShare); } } else { targetedShare.setPackage(info.activityInfo.packageName); targetedShareIntents.add(targetedShare); } } Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Select app to share"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[] {})); res = chooserIntent; if (launch) { context.startActivity(chooserIntent); } } return res; }
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);//w ww . j a v a2 s. c o m 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("[ ] "); }/* www .j ava 2 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:com.jtschohl.androidfirewall.MainActivity.java
/** * Email error reports//from w w w. ja v a 2 s . c om */ private void emailErrorReports() { File sdCard = Environment.getExternalStorageDirectory(); File dir = new File(sdCard.getAbsolutePath() + "/af_error_reports/"); String filename = "af_error_reports.zip"; File file = new File(dir, filename); String af_version; try { af_version = getApplicationContext().getPackageManager() .getPackageInfo(getApplicationContext().getPackageName(), 0).versionName; } catch (NameNotFoundException e) { af_version = "Unknown"; } Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "androidfirewall.developer@gmail.com" }); intent.putExtra(Intent.EXTRA_SUBJECT, "Android Firewall Error Report for version " + af_version); intent.putExtra(Intent.EXTRA_TEXT, ""); if (!file.exists() || !file.canRead()) { Toast.makeText(this, R.string.no_zip, Toast.LENGTH_SHORT).show(); Log.d(TAG, "No zip file is available"); finish(); return; } Uri uri = Uri.fromFile(file); intent.putExtra(Intent.EXTRA_STREAM, uri); startActivity(Intent.createChooser(intent, getString(R.string.send_email))); return; }
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 a v a 2s . co m 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 w w . j av a2 s . c o m*/ */ 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); } } }); }