List of usage examples for android.content Intent EXTRA_EMAIL
String EXTRA_EMAIL
To view the source code for android.content Intent EXTRA_EMAIL.
Click Source Link
From source file:org.sufficientlysecure.keychain.ui.EncryptFilesFragment.java
private Intent createSendIntent() { Intent sendIntent;//w ww . j a va 2 s . c om // file if (mOutputUris.size() == 1) { sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_STREAM, mOutputUris.get(0)); } else { sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE); sendIntent.putExtra(Intent.EXTRA_STREAM, mOutputUris); } sendIntent.setType(Constants.MIME_TYPE_ENCRYPTED_ALTERNATE); EncryptActivity modeInterface = (EncryptActivity) getActivity(); EncryptModeFragment modeFragment = modeInterface.getModeFragment(); if (!modeFragment.isAsymmetric()) { return sendIntent; } String[] encryptionUserIds = modeFragment.getAsymmetricEncryptionUserIds(); if (encryptionUserIds == null) { return sendIntent; } Set<String> users = new HashSet<>(); for (String user : encryptionUserIds) { OpenPgpUtils.UserId userId = KeyRing.splitUserId(user); if (userId.email != null) { users.add(userId.email); } } // pass trough email addresses as extra for email applications sendIntent.putExtra(Intent.EXTRA_EMAIL, users.toArray(new String[users.size()])); return sendIntent; }
From source file:org.totschnig.myexpenses.util.Utils.java
public static void share(Context ctx, ArrayList<Uri> fileUris, String target, String mimeType) { URI uri = null;/* w w w . ja v a 2 s .c o m*/ Intent intent; String scheme = "mailto"; boolean multiple = fileUris.size() > 1; if (!target.equals("")) { uri = Utils.validateUri(target); if (uri == null) { Toast.makeText(ctx, ctx.getString(R.string.ftp_uri_malformed, target), Toast.LENGTH_LONG).show(); return; } scheme = uri.getScheme(); } // if we get a String that does not include a scheme, // we interpret it as a mail address if (scheme == null) { scheme = "mailto"; } if (scheme.equals("ftp")) { if (multiple) { Toast.makeText(ctx, "sending multiple file through ftp is not supported", Toast.LENGTH_LONG).show(); return; } intent = new Intent(android.content.Intent.ACTION_SENDTO); intent.putExtra(Intent.EXTRA_STREAM, fileUris.get(0)); intent.setDataAndType(android.net.Uri.parse(target), mimeType); if (!isIntentAvailable(ctx, intent)) { Toast.makeText(ctx, R.string.no_app_handling_ftp_available, Toast.LENGTH_LONG).show(); return; } ctx.startActivity(intent); } else if (scheme.equals("mailto")) { if (multiple) { intent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE); ArrayList<Uri> uris = new ArrayList<>(); for (Uri fileUri : fileUris) { uris.add(fileUri); } intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); } else { intent = new Intent(android.content.Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_STREAM, fileUris.get(0)); } intent.setType(mimeType); if (uri != null) { String address = uri.getSchemeSpecificPart(); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { address }); } intent.putExtra(Intent.EXTRA_SUBJECT, R.string.export_expenses); if (!isIntentAvailable(ctx, intent)) { Toast.makeText(ctx, R.string.no_app_handling_email_available, Toast.LENGTH_LONG).show(); return; } // if we got mail address, we launch the default application // if we are called without target, we launch the chooser // in order to make action more explicit if (uri != null) { ctx.startActivity(intent); } else { ctx.startActivity(Intent.createChooser(intent, ctx.getString(R.string.share_sending))); } } else { Toast.makeText(ctx, ctx.getString(R.string.share_scheme_not_supported, scheme), Toast.LENGTH_LONG) .show(); return; } }
From source file:com.googlecode.CallerLookup.Main.java
public void doSubmit() { String entry = ""; if (mLookup.getSelectedItemPosition() != 0) { entry = mLookup.getSelectedItem().toString() + "\n"; }//from w ww. jav a2 s . c o m entry += mURL.getText().toString() + "\n"; entry += mRegExp.getText().toString() + "\n"; try { String[] mailto = { EMAIL_ADDRESS }; Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_EMAIL, mailto); sendIntent.putExtra(Intent.EXTRA_SUBJECT, EMAIL_SUBJECT); sendIntent.putExtra(Intent.EXTRA_TEXT, entry); sendIntent.setType("message/rfc822"); startActivity(sendIntent); } catch (ActivityNotFoundException e) { e.printStackTrace(); AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(R.string.SubmitFailureTitle); alert.setMessage(R.string.SubmitFailureMessage); alert.setPositiveButton(android.R.string.ok, null); alert.show(); } }
From source file:com.shurik.droidzebra.DroidZebra.java
private void sendMail() { //GetNowTime// ww w .j a v a2 s . co m Calendar calendar = Calendar.getInstance(); Date nowTime = calendar.getTime(); StringBuffer sbBlackPlayer = new StringBuffer(); StringBuffer sbWhitePlayer = new StringBuffer(); ZebraEngine.GameState gs = mZebraThread.getGameState(); SharedPreferences settings = getSharedPreferences(SHARED_PREFS_NAME, 0); byte[] moves = null; if (gs != null) { moves = gs.mMoveSequence; } Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { settings.getString(SETTINGS_KEY_SENDMAIL, DEFAULT_SETTING_SENDMAIL) }); intent.putExtra(Intent.EXTRA_SUBJECT, "DroidZebra"); //get BlackPlayer and WhitePlayer switch (mSettingFunction) { case FUNCTION_HUMAN_VS_HUMAN: sbBlackPlayer.append("Player"); sbWhitePlayer.append("Player"); break; case FUNCTION_ZEBRA_BLACK: sbBlackPlayer.append("DroidZebra-"); sbBlackPlayer.append(mSettingZebraDepth); sbBlackPlayer.append("/"); sbBlackPlayer.append(mSettingZebraDepthExact); sbBlackPlayer.append("/"); sbBlackPlayer.append(mSettingZebraDepthWLD); sbWhitePlayer.append("Player"); break; case FUNCTION_ZEBRA_WHITE: sbBlackPlayer.append("Player"); sbWhitePlayer.append("DroidZebra-"); sbWhitePlayer.append(mSettingZebraDepth); sbWhitePlayer.append("/"); sbWhitePlayer.append(mSettingZebraDepthExact); sbWhitePlayer.append("/"); sbWhitePlayer.append(mSettingZebraDepthWLD); break; case FUNCTION_ZEBRA_VS_ZEBRA: sbBlackPlayer.append("DroidZebra-"); sbBlackPlayer.append(mSettingZebraDepth); sbBlackPlayer.append("/"); sbBlackPlayer.append(mSettingZebraDepthExact); sbBlackPlayer.append("/"); sbBlackPlayer.append(mSettingZebraDepthWLD); sbWhitePlayer.append("DroidZebra-"); sbWhitePlayer.append(mSettingZebraDepth); sbWhitePlayer.append("/"); sbWhitePlayer.append(mSettingZebraDepthExact); sbWhitePlayer.append("/"); sbWhitePlayer.append(mSettingZebraDepthWLD); default: } StringBuffer sb = new StringBuffer(); sb.append(getResources().getString(R.string.mail_generated)); sb.append("\r\n"); sb.append(getResources().getString(R.string.mail_date)); sb.append(" "); sb.append(nowTime); sb.append("\r\n\r\n"); sb.append(getResources().getString(R.string.mail_move)); sb.append(" "); StringBuffer sbMoves = new StringBuffer(); if (moves != null) { for (int i = 0; i < moves.length; i++) { if (moves[i] != 0x00) { Move move = new Move(moves[i]); sbMoves.append(move.getText()); if (mLastMove.getText().equals(move.getText())) { break; } } } } sb.append(sbMoves); sb.append("\r\n\r\n"); sb.append(sbBlackPlayer.toString()); sb.append(" (B) "); sb.append(mBlackScore); sb.append(":"); sb.append(mWhiteScore); sb.append(" (W) "); sb.append(sbWhitePlayer.toString()); sb.append("\r\n\r\n"); sb.append(getResources().getString(R.string.mail_url)); sb.append("\r\n"); sb.append(getResources().getString(R.string.mail_viewer_url)); sb.append("lm="); sb.append(sbMoves); sb.append("&bp="); sb.append(sbBlackPlayer.toString()); sb.append("&wp="); sb.append(sbWhitePlayer.toString()); sb.append("&bs="); sb.append(mBlackScore); sb.append("&ws="); sb.append(mWhiteScore); intent.putExtra(Intent.EXTRA_TEXT, sb.toString()); // Intent this.startActivity(intent); }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
private void emailLog(final CallbackContext callback, final String email) { cordova.getThreadPool().execute(new Runnable() { public void run() { String log = readLog(); if (log == null) { callback.error(500);//from www. ja v a 2 s . c o m return; } Intent mailer = new Intent(Intent.ACTION_SEND); mailer.setType("message/rfc822"); mailer.putExtra(Intent.EXTRA_EMAIL, new String[] { email }); mailer.putExtra(Intent.EXTRA_SUBJECT, "BackgroundGeolocation log"); try { JSONObject state = getState(); if (state.has("license")) { state.put("license", "<SECRET>"); } if (state.has("orderId")) { state.put("orderId", "<SECRET>"); } mailer.putExtra(Intent.EXTRA_TEXT, state.toString(4)); } catch (JSONException e) { Log.w(TAG, "- Failed to write state to email body"); e.printStackTrace(); } File file = new File(Environment.getExternalStorageDirectory(), "background-geolocation.log"); try { FileOutputStream stream = new FileOutputStream(file); try { stream.write(log.getBytes()); stream.close(); mailer.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); file.deleteOnExit(); } catch (IOException e) { e.printStackTrace(); } } catch (FileNotFoundException e) { Log.i(TAG, "FileNotFound"); e.printStackTrace(); } try { cordova.getActivity() .startActivityForResult(Intent.createChooser(mailer, "Send log: " + email + "..."), 1); callback.success(); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(cordova.getActivity(), "There are no email clients installed.", Toast.LENGTH_SHORT).show(); callback.error("There are no email clients installed"); } } }); }
From source file:com.irccloud.android.activity.BaseActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_logout: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Logout"); builder.setMessage("Would you like to logout of IRCCloud?"); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override/*from w w w .j a v a 2 s . c om*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setPositiveButton("Logout", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); conn.logout(); if (mGoogleApiClient.isConnected()) { Auth.CredentialsApi.disableAutoSignIn(mGoogleApiClient) .setResultCallback(new ResultCallback<Status>() { @Override public void onResult(Status status) { Intent i = new Intent(BaseActivity.this, LoginActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); finish(); } }); } else { Intent i = new Intent(BaseActivity.this, LoginActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); finish(); } } }); AlertDialog dialog = builder.create(); dialog.setOwnerActivity(this); dialog.show(); break; case R.id.menu_settings: Intent i = new Intent(this, PreferencesActivity.class); startActivity(i); break; case R.id.menu_feedback: try { String bugReport = "Briefly describe the issue below:\n\n\n\n\n" + "===========\n" + ((NetworkConnection.getInstance().getUserInfo() != null) ? ("UID: " + NetworkConnection.getInstance().getUserInfo().id + "\n") : "") + "App version: " + getPackageManager().getPackageInfo(getPackageName(), 0).versionName + " (" + getPackageManager().getPackageInfo(getPackageName(), 0).versionCode + ")\n" + "Device: " + Build.MODEL + "\n" + "Android version: " + Build.VERSION.RELEASE + "\n" + "Firmware fingerprint: " + Build.FINGERPRINT + "\n"; File logsDir = new File(getFilesDir(), ".Fabric/com.crashlytics.sdk.android.crashlytics-core/log-files/"); File log = null; File output = null; if (logsDir.exists()) { long max = Long.MIN_VALUE; for (File f : logsDir.listFiles()) { if (f.lastModified() > max) { max = f.lastModified(); log = f; } } if (log != null) { File f = new File(getFilesDir(), "logs"); f.mkdirs(); output = new File(f, LOG_FILENAME); byte[] b = new byte[1]; FileOutputStream out = new FileOutputStream(output); FileInputStream is = new FileInputStream(log); is.skip(5); while (is.available() > 0 && is.read(b, 0, 1) > 0) { if (b[0] == ' ') { while (is.available() > 0 && is.read(b, 0, 1) > 0) { out.write(b); if (b[0] == '\n') break; } } } is.close(); out.close(); } } Intent email = new Intent(Intent.ACTION_SEND); email.setData(Uri.parse("mailto:")); email.setType("message/rfc822"); email.putExtra(Intent.EXTRA_EMAIL, new String[] { "IRCCloud Team <team@irccloud.com>" }); email.putExtra(Intent.EXTRA_TEXT, bugReport); email.putExtra(Intent.EXTRA_SUBJECT, "IRCCloud for Android"); if (log != null) { email.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", output)); } startActivityForResult(Intent.createChooser(email, "Send Feedback:"), 0); } catch (Exception e) { Toast.makeText(this, "Unable to generate email report: " + e.getMessage(), Toast.LENGTH_SHORT) .show(); Crashlytics.logException(e); NetworkConnection.printStackTraceToCrashlytics(e); } break; } return super.onOptionsItemSelected(item); }
From source file:com.pacoapp.paco.ui.MyExperimentsActivity.java
public void launchEmailTo(final String emailAddress) { Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); String aEmailList[] = { emailAddress }; emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.email_subject_paco_feedback)); emailIntent.setType("plain/text"); startActivity(emailIntent);/*from w ww . j a v a 2 s . c om*/ }
From source file:org.torproject.android.OrbotMainActivity.java
private void sendGetBridgeEmail(String type) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "bridges@torproject.org" }); if (type != null) { intent.putExtra(Intent.EXTRA_SUBJECT, "get transport " + type); intent.putExtra(Intent.EXTRA_TEXT, "get transport " + type); } else {/* ww w .jav a2 s. co m*/ intent.putExtra(Intent.EXTRA_SUBJECT, "get bridges"); intent.putExtra(Intent.EXTRA_TEXT, "get bridges"); } startActivity(Intent.createChooser(intent, getString(R.string.send_email))); }
From source file:de.mkrtchyan.recoverytools.RecoveryTools.java
public void report(final boolean isCancelable) { final Dialog reportDialog = mNotifyer.createDialog(R.string.commentar, R.layout.dialog_comment, false, true);/*from ww w . j a va 2 s.c o m*/ new Thread(new Runnable() { @Override public void run() { /** Creates a report Email including a Comment and important device infos */ final Button bGo = (Button) reportDialog.findViewById(R.id.bGo); bGo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!Common.getBooleanPref(mContext, PREF_NAME, PREF_KEY_ADS)) Toast.makeText(mContext, R.string.please_ads, Toast.LENGTH_SHORT).show(); Toast.makeText(mContext, R.string.donate_to_support, Toast.LENGTH_SHORT).show(); try { ArrayList<File> files = new ArrayList<File>(); File TestResults = new File(mContext.getFilesDir(), "results.txt"); try { if (TestResults.exists()) { if (TestResults.delete()) { FileOutputStream fos = openFileOutput(TestResults.getName(), Context.MODE_PRIVATE); fos.write(("Recovery-Tools:\n\n" + mShell.execCommand( "ls -lR " + PathToRecoveryTools.getAbsolutePath()) + "\nCache Tree:\n" + mShell.execCommand("ls -lR /cache") + "\n" + "\nMTD result:\n" + mShell.execCommand("cat /proc/mtd") + "\n" + "\nDevice Tree:\n\n" + mShell.execCommand("ls -lR /dev")) .getBytes()); } files.add(TestResults); } } catch (FileNotFoundException e) { e.printStackTrace(); } if (getPackageManager() != null) { PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); EditText text = (EditText) reportDialog.findViewById(R.id.etComment); String comment = ""; if (text.getText() != null) comment = text.getText().toString(); Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "ashotmkrtchyan1995@gmail.com" }); intent.putExtra(Intent.EXTRA_SUBJECT, "Recovery-Tools report"); intent.putExtra(Intent.EXTRA_TEXT, "Package Infos:" + "\n\nName: " + pInfo.packageName + "\nVersionName: " + pInfo.versionName + "\nVersionCode: " + pInfo.versionCode + "\n\n\nProduct Info: " + "\n\nManufacture: " + android.os.Build.MANUFACTURER + "\nDevice: " + Build.DEVICE + " (" + mDevice.getDeviceName() + ")" + "\nBoard: " + Build.BOARD + "\nBrand: " + Build.BRAND + "\nModel: " + Build.MODEL + "\nFingerprint: " + Build.FINGERPRINT + "\nAndroid SDK Level: " + Build.VERSION.CODENAME + " (" + Build.VERSION.SDK_INT + ")" + "\nRecovery Supported: " + mDevice.isRecoverySupported() + "\nRecovery Path: " + mDevice.getRecoveryPath() + "\nRecovery Version: " + mDevice.getRecoveryVersion() + "\nRecovery MTD: " + mDevice.isRecoveryMTD() + "\nRecovery DD: " + mDevice.isRecoveryDD() + "\nKernel Supported: " + mDevice.isKernelSupported() + "\nKernel Path: " + mDevice.getKernelPath() + "\nKernel Version: " + mDevice.getKernelVersion() + "\nKernel MTD: " + mDevice.isKernelMTD() + "\nKernel DD: " + mDevice.isKernelDD() + "\n\nCWM: " + mDevice.isCwmSupported() + "\nTWRP: " + mDevice.isTwrpSupported() + "\nPHILZ: " + mDevice.isPhilzSupported() + "\n\n\n===========COMMENT==========\n" + comment + "\n===========COMMENT END==========\n" + "\n===========PREFS==========\n" + getAllPrefs() + "\n===========PREFS END==========\n"); File CommandLogs = new File(mContext.getFilesDir(), Shell.Logs); if (CommandLogs.exists()) { files.add(CommandLogs); } files.add(new File(getFilesDir(), "last_log.txt")); ArrayList<Uri> uris = new ArrayList<Uri>(); for (File file : files) { mShell.execCommand("cp " + file.getAbsolutePath() + " " + new File(mContext.getFilesDir(), file.getName()).getAbsolutePath()); file = new File(mContext.getFilesDir(), file.getName()); mToolbox.setFilePermissions(file, "644"); uris.add(Uri.fromFile(file)); } intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); startActivity(Intent.createChooser(intent, "Send over Gmail")); reportDialog.dismiss(); } } catch (Exception e) { reportDialog.dismiss(); Notifyer.showExceptionToast(mContext, TAG, e); } } }); } }).start(); reportDialog.setCancelable(isCancelable); reportDialog.show(); }
From source file:org.kiwix.kiwixmobile.KiwixMobileActivity.java
public void sendContactEmail() { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("plain/text"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { contactEmailAddress }); intent.putExtra(Intent.EXTRA_SUBJECT, "Feedback in " + LanguageUtils.getCurrentLocale(this).getDisplayLanguage()); startActivity(Intent.createChooser(intent, "")); }