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:gr.scify.newsum.ui.ViewActivity.java
private void Sendmail() { TextView title = (TextView) findViewById(R.id.title); String emailSubject = title.getText().toString(); // track the Send mail action if (getAnalyticsPref()) { EasyTracker.getTracker().sendEvent(SHARING_ACTION, "Send Mail", emailSubject, 0l); }/*from w ww . ja v a 2s . c om*/ final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/html"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "NewSum app : " + emailSubject); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(sText)); startActivity(Intent.createChooser(emailIntent, "Email:")); }
From source file:ch.luklanis.esscan.history.HistoryActivity.java
private Intent createShareIntent(String mime, Uri dtaFileUri) { String[] recipients = new String[] { PreferenceManager.getDefaultSharedPreferences(this) .getString(PreferencesActivity.KEY_EMAIL_ADDRESS, "") }; String subject = getResources().getString(R.string.history_share_as_dta_title); String text = String.format(getResources().getString(R.string.history_share_as_dta_summary), dtaFileUri.getPath());/* w w w .j ava2s . com*/ Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:")); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.setType(mime); intent.putExtra(Intent.EXTRA_EMAIL, recipients); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, text); intent.putExtra(Intent.EXTRA_STREAM, dtaFileUri); return intent; }
From source file:com.balakrish.gpstracker.WaypointsListActivity.java
/** * Handle activity menu/* w w w . jav a2s. c o m*/ */ @Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); final long waypointId = waypointsArrayAdapter.getItem((int) info.id).getId(); Cursor tmpCursor; String sql; switch (item.getItemId()) { case 0: // update waypoint in db updateWaypoint(waypointId); return true; case 1: deleteWaypoint(waypointId); return true; case 2: // email waypoint data using default email client String elevationUnit = app.getPreferences().getString("elevation_units", "m"); String elevationUnitLocalized = Utils.getLocalizedElevationUnit(this, elevationUnit); sql = "SELECT * FROM waypoints WHERE _id=" + waypointId + ";"; tmpCursor = app.getDatabase().rawQuery(sql, null); tmpCursor.moveToFirst(); double lat1 = tmpCursor.getDouble(tmpCursor.getColumnIndex("lat")) / 1E6; double lng1 = tmpCursor.getDouble(tmpCursor.getColumnIndex("lng")) / 1E6; String messageBody = getString(R.string.title) + ": " + tmpCursor.getString(tmpCursor.getColumnIndex("title")) + "\n\n" + getString(R.string.lat) + ": " + Utils.formatLat(lat1, 0) + "\n" + getString(R.string.lng) + ": " + Utils.formatLng(lng1, 0) + "\n" + getString(R.string.elevation) + ": " + Utils.formatElevation(tmpCursor.getFloat(tmpCursor.getColumnIndex("elevation")), elevationUnit) + elevationUnitLocalized + "\n\n" + "http://maps.google.com/?ll=" + lat1 + "," + lng1 + "&z=10"; tmpCursor.close(); final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject_waypoint)); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, messageBody); this.startActivity(Intent.createChooser(emailIntent, getString(R.string.sending_email))); return true; case 3: this.showOnMap(waypointId); return true; case 4: // TODO: use a thread for online sync // sync one waypoint data with remote server // create temp waypoint from current record Waypoint wp = Waypoints.get(app.getDatabase(), waypointId); try { // preparing query string for calling web service String lat = Location.convert(wp.getLocation().getLatitude(), 0); String lng = Location.convert(wp.getLocation().getLongitude(), 0); String title = URLEncoder.encode(wp.getTitle()); String userName = app.getPreferences().getString("user_name", ""); String userPassword = app.getPreferences().getString("user_password", ""); String sessionValue = userName + "@" + Utils.md5("aripuca_session" + userPassword); if (userName.equals("") || userPassword.equals("")) { Toast.makeText(WaypointsListActivity.this, R.string.username_or_password_required, Toast.LENGTH_SHORT).show(); return false; } String queryString = "?do=ajax_map_handler&aripuca_session=" + sessionValue + "&action=add_point&lat=" + lat + "&lng=" + lng + "&z=16&n=" + title + "&d=AndroidSync"; // http connection HttpClient httpClient = new DefaultHttpClient(); HttpContext localContext = new BasicHttpContext(); HttpGet httpGet = new HttpGet( app.getPreferences().getString("online_sync_url", "http://tracker.aripuca.com") + queryString); HttpResponse response = httpClient.execute(httpGet, localContext); ByteArrayOutputStream outstream = new ByteArrayOutputStream(); response.getEntity().writeTo(outstream); // parsing JSON return JSONObject jsonObject = new JSONObject(outstream.toString()); Toast.makeText(WaypointsListActivity.this, jsonObject.getString("message").toString(), Toast.LENGTH_SHORT).show(); } catch (ClientProtocolException e) { Toast.makeText(WaypointsListActivity.this, "ClientProtocolException: " + e.getMessage(), Toast.LENGTH_SHORT).show(); } catch (IOException e) { Toast.makeText(WaypointsListActivity.this, "IOException " + e.getMessage(), Toast.LENGTH_SHORT) .show(); } catch (JSONException e) { Toast.makeText(WaypointsListActivity.this, "JSONException " + e.getMessage(), Toast.LENGTH_SHORT) .show(); } return true; default: return super.onContextItemSelected(item); } }
From source file:it.feio.android.omninotes.DetailFragment.java
private void handleIntents() { Intent i = mainActivity.getIntent(); if (IntentChecker.checkAction(i, Constants.ACTION_MERGE)) { noteOriginal = new Note(); note = new Note(noteOriginal); noteTmp = getArguments().getParcelable(Constants.INTENT_NOTE); if (i.getStringArrayListExtra("merged_notes") != null) { mergedNotesIds = i.getStringArrayListExtra("merged_notes"); }/*w w w . j av a 2s . c o m*/ } // Action called from home shortcut if (IntentChecker.checkAction(i, Constants.ACTION_SHORTCUT, Constants.ACTION_NOTIFICATION_CLICK)) { afterSavedReturnsToList = false; noteOriginal = DbHelper.getInstance().getNote(i.getLongExtra(Constants.INTENT_KEY, 0)); // Checks if the note pointed from the shortcut has been deleted try { note = new Note(noteOriginal); noteTmp = new Note(noteOriginal); } catch (NullPointerException e) { mainActivity.showToast(getText(R.string.shortcut_note_deleted), Toast.LENGTH_LONG); mainActivity.finish(); } } // Check if is launched from a widget if (IntentChecker.checkAction(i, Constants.ACTION_WIDGET, Constants.ACTION_TAKE_PHOTO)) { afterSavedReturnsToList = false; showKeyboard = true; // with tags to set tag if (i.hasExtra(Constants.INTENT_WIDGET)) { String widgetId = i.getExtras().get(Constants.INTENT_WIDGET).toString(); if (widgetId != null) { String sqlCondition = prefs.getString(Constants.PREF_WIDGET_PREFIX + widgetId, ""); String categoryId = TextHelper.checkIntentCategory(sqlCondition); if (categoryId != null) { Category category; try { category = DbHelper.getInstance().getCategory(Long.parseLong(categoryId)); noteTmp = new Note(); noteTmp.setCategory(category); } catch (NumberFormatException e) { Log.e(Constants.TAG, "Category with not-numeric value!", e); } } } } // Sub-action is to take a photo if (IntentChecker.checkAction(i, Constants.ACTION_TAKE_PHOTO)) { takePhoto(); } } /** * Handles third party apps requests of sharing */ if (IntentChecker.checkAction(i, Intent.ACTION_SEND, Intent.ACTION_SEND_MULTIPLE, Constants.INTENT_GOOGLE_NOW) && i.getType() != null) { afterSavedReturnsToList = false; if (noteTmp == null) noteTmp = new Note(); // Text title String title = i.getStringExtra(Intent.EXTRA_SUBJECT); if (title != null) { noteTmp.setTitle(title); } // Text content String content = i.getStringExtra(Intent.EXTRA_TEXT); if (content != null) { noteTmp.setContent(content); } // Single attachment data Uri uri = i.getParcelableExtra(Intent.EXTRA_STREAM); // Due to the fact that Google Now passes intent as text but with // audio recording attached the case must be handled in specific way if (uri != null && !Constants.INTENT_GOOGLE_NOW.equals(i.getAction())) { String name = FileHelper.getNameFromUri(mainActivity, uri); AttachmentTask task = new AttachmentTask(this, uri, name, this); task.execute(); } // Multiple attachment data ArrayList<Uri> uris = i.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (uris != null) { for (Uri uriSingle : uris) { String name = FileHelper.getNameFromUri(mainActivity, uriSingle); AttachmentTask task = new AttachmentTask(this, uriSingle, name, this); task.execute(); } } // i.setAction(null); } if (IntentChecker.checkAction(i, Intent.ACTION_MAIN, Constants.ACTION_WIDGET_SHOW_LIST)) { showKeyboard = true; } }
From source file:de.ub0r.android.callmeter.ui.prefs.Preferences.java
/** * Export data./*from w w w. j av a 2s. c om*/ * * @param descr * description of the exported rule set * @param fn * one of the predefined file names from {@link DataProvider}. */ private void exportData(final String descr, final String fn) { if (descr == null) { final EditText et = new EditText(this); Builder builder = new Builder(this); builder.setView(et); builder.setCancelable(true); builder.setTitle(R.string.export_rules_descr); builder.setNegativeButton(android.R.string.cancel, null); builder.setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { Preferences.this.exportData(et.getText().toString(), fn); } }); builder.show(); } else { final ProgressDialog d = new ProgressDialog(this); d.setIndeterminate(true); d.setMessage(this.getString(R.string.export_progr)); d.setCancelable(false); d.show(); // run task in background final AsyncTask<Void, Void, String> task = // . new AsyncTask<Void, Void, String>() { @Override protected String doInBackground(final Void... params) { if (fn.equals(DataProvider.EXPORT_RULESET_FILE)) { return DataProvider.backupRuleSet(Preferences.this, descr); } else if (fn.equals(DataProvider.EXPORT_LOGS_FILE)) { return DataProvider.backupLogs(Preferences.this, descr); } else if (fn.equals(DataProvider.EXPORT_NUMGROUPS_FILE)) { return DataProvider.backupNumGroups(Preferences.this, descr); } else if (fn.equals(DataProvider.EXPORT_HOURGROUPS_FILE)) { return DataProvider.backupHourGroups(Preferences.this, descr); } return null; } @Override protected void onPostExecute(final String result) { Log.d(TAG, "export:\n" + result); System.out.println("\n" + result); d.dismiss(); if (result != null && result.length() > 0) { Uri uri = null; int resChooser = -1; if (fn.equals(DataProvider.EXPORT_RULESET_FILE)) { uri = DataProvider.EXPORT_RULESET_URI; resChooser = R.string.export_rules_; } else if (fn.equals(DataProvider.EXPORT_LOGS_FILE)) { uri = DataProvider.EXPORT_LOGS_URI; resChooser = R.string.export_logs_; } else if (fn.equals(DataProvider.EXPORT_NUMGROUPS_FILE)) { uri = DataProvider.EXPORT_NUMGROUPS_URI; resChooser = R.string.export_numgroups_; } else if (fn.equals(DataProvider.EXPORT_HOURGROUPS_FILE)) { uri = DataProvider.EXPORT_HOURGROUPS_URI; resChooser = R.string.export_hourgroups_; } final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType(DataProvider.EXPORT_MIMETYPE); intent.putExtra(Intent.EXTRA_STREAM, uri); intent.putExtra(Intent.EXTRA_SUBJECT, // . "Call Meter 3G export"); intent.addCategory(Intent.CATEGORY_DEFAULT); try { final File d = Environment.getExternalStorageDirectory(); final File f = new File(d, DataProvider.PACKAGE + File.separator + fn); f.mkdirs(); if (f.exists()) { f.delete(); } f.createNewFile(); FileWriter fw = new FileWriter(f); fw.append(result); fw.close(); // call an exporting app with the uri to the // preferences Preferences.this.startActivity( Intent.createChooser(intent, Preferences.this.getString(resChooser))); } catch (IOException e) { Log.e(TAG, "error writing export file", e); Toast.makeText(Preferences.this, R.string.err_export_write, Toast.LENGTH_LONG) .show(); } } } }; task.execute((Void) null); } }
From source file:com.dycody.android.idealnote.DetailFragment.java
private void handleIntents() { Intent i = mainActivity.getIntent(); if (IntentChecker.checkAction(i, Constants.ACTION_MERGE)) { noteOriginal = new Note(); note = new Note(noteOriginal); noteTmp = getArguments().getParcelable(Constants.INTENT_NOTE); if (i.getStringArrayListExtra("merged_notes") != null) { mergedNotesIds = i.getStringArrayListExtra("merged_notes"); }/* w w w .j a va 2 s . co m*/ } // Action called from home shortcut if (IntentChecker.checkAction(i, Constants.ACTION_SHORTCUT, Constants.ACTION_NOTIFICATION_CLICK)) { afterSavedReturnsToList = false; noteOriginal = DbHelper.getInstance().getNote(i.getLongExtra(Constants.INTENT_KEY, 0)); // Checks if the note pointed from the shortcut has been deleted try { note = new Note(noteOriginal); noteTmp = new Note(noteOriginal); } catch (NullPointerException e) { mainActivity.showToast(getText(R.string.shortcut_note_deleted), Toast.LENGTH_LONG); mainActivity.finish(); } } // Check if is launched from a widget if (IntentChecker.checkAction(i, Constants.ACTION_WIDGET, Constants.ACTION_TAKE_PHOTO)) { afterSavedReturnsToList = false; showKeyboard = true; // with tags to set tag if (i.hasExtra(Constants.INTENT_WIDGET)) { String widgetId = i.getExtras().get(Constants.INTENT_WIDGET).toString(); if (widgetId != null) { String sqlCondition = prefs.getString(Constants.PREF_WIDGET_PREFIX + widgetId, ""); String categoryId = TextHelper.checkIntentCategory(sqlCondition); if (categoryId != null) { Category category; try { category = DbHelper.getInstance().getCategory(Long.parseLong(categoryId)); noteTmp = new Note(); noteTmp.setCategory(category); } catch (NumberFormatException e) { Log.e(Constants.TAG, "Category with not-numeric value!", e); } } } } // Sub-action is to take a photo if (IntentChecker.checkAction(i, Constants.ACTION_TAKE_PHOTO)) { takePhoto(); } } /** * Handles third party apps requests of sharing */ if (IntentChecker.checkAction(i, Intent.ACTION_SEND, Intent.ACTION_SEND_MULTIPLE, Constants.INTENT_GOOGLE_NOW) && i.getType() != null) { afterSavedReturnsToList = false; if (noteTmp == null) noteTmp = new Note(); // Text title String title = i.getStringExtra(Intent.EXTRA_SUBJECT); if (title != null) { noteTmp.setTitle(title); } // Text content String content = i.getStringExtra(Intent.EXTRA_TEXT); if (content != null) { noteTmp.setContent(content); } // Single attachment data Uri uri = i.getParcelableExtra(Intent.EXTRA_STREAM); // Due to the fact that Google Now passes intent as text but with // audio recording attached the case must be handled in specific way if (uri != null && !Constants.INTENT_GOOGLE_NOW.equals(i.getAction())) { String name = FileHelper.getNameFromUri(mainActivity, uri); new AttachmentTask(this, uri, name, this).execute(); } // Multiple attachment data ArrayList<Uri> uris = i.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (uris != null) { for (Uri uriSingle : uris) { String name = FileHelper.getNameFromUri(mainActivity, uriSingle); new AttachmentTask(this, uriSingle, name, this).execute(); } } } if (IntentChecker.checkAction(i, Intent.ACTION_MAIN, Constants.ACTION_WIDGET_SHOW_LIST, Constants.ACTION_SHORTCUT_WIDGET, Constants.ACTION_WIDGET)) { showKeyboard = true; } i.setAction(null); }
From source file:com.downrighttech.dmxdip.MainActivity.java
public void buildIntent() { if (mShareIntent == null) return;// www . j a v a2 s. c om int pref_start = mSharedPreferences.getInt("pref_start", mFirstAddress); int pref_span = mSharedPreferences.getInt("pref_span", 1); mShareIntent.putExtra(Intent.EXTRA_SUBJECT, "AndroDip - Start:" + pref_start + " Span:" + pref_span); buildHTML bh = new buildHTML(mAddressArray, mBitArray); mShareIntent.putExtra(Intent.EXTRA_TEXT, bh.getText()); if (VERSION.SDK_INT >= 14) mShareActionProvider.setShareIntent(mShareIntent); }
From source file:ac.robinson.ticqr.TicQRActivity.java
private void sendOrder() { try {/*from w ww . j a va 2 s . c o m*/ Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", TextUtils.isEmpty(mDestinationEmail) ? "" : mDestinationEmail, null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.email_subject)); emailIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.email_body, mEmailContents)); startActivity(Intent.createChooser(emailIntent, getString(R.string.email_prompt))); } catch (ActivityNotFoundException e) { // copy to clipboard instead if no email client found String clipboardText = getString(R.string.email_backup_sender, TextUtils.isEmpty(mDestinationEmail) ? "" : mDestinationEmail, getString(R.string.email_body, mEmailContents)); // see: http://stackoverflow.com/a/11012443 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { @SuppressLint("ServiceCast") @SuppressWarnings("deprecation") android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); clipboard.setText(clipboardText); } else { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData .newPlainText(getString(R.string.email_subject), clipboardText); clipboard.setPrimaryClip(clip); } Toast.makeText(TicQRActivity.this, getString(R.string.hint_no_email_client), Toast.LENGTH_LONG).show(); } }
From source file:cn.ucai.wechat.ui.SettingsActivity.java
void sendLogThroughMail() { String logPath = ""; try {/* w w w. j a v a2s . c o m*/ logPath = EMClient.getInstance().compressLogs(); } catch (Exception e) { e.printStackTrace(); runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(SettingsActivity.this, "compress logs failed", Toast.LENGTH_LONG).show(); } }); return; } File f = new File(logPath); File storage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); if (f.exists() && f.canRead()) { try { storage.mkdirs(); File temp = File.createTempFile("hyphenate", ".log.gz", storage); if (!temp.canWrite()) { return; } boolean result = f.renameTo(temp); if (result == false) { return; } Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.setData(Uri.parse("mailto:")); intent.putExtra(Intent.EXTRA_SUBJECT, "log"); intent.putExtra(Intent.EXTRA_TEXT, "log in attachment: " + temp.getAbsolutePath()); intent.setType("application/octet-stream"); ArrayList<Uri> uris = new ArrayList<>(); uris.add(Uri.fromFile(temp)); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); startActivity(intent); } catch (final Exception e) { e.printStackTrace(); runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(SettingsActivity.this, e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } }); } } }