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.apache.cordova.EmailComposer.java
private void sendEmail(JSONObject parameters) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE); // String callback = parameters.getString("callback"); System.out.println(parameters.toString()); boolean isHTML = false; try {/* ww w .j a va 2 s.co m*/ isHTML = parameters.getBoolean("bIsHTML"); } catch (Exception e) { LOG.e("EmailComposer", "Error handling isHTML param: " + e.toString()); } if (isHTML) { emailIntent.setType("text/html"); } else { emailIntent.setType("text/plain"); } // setting subject try { String subject = parameters.getString("subject"); if (subject != null && subject.length() > 0) { emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); } } catch (Exception e) { LOG.e("EmailComposer", "Error handling subject param: " + e.toString()); } // setting body try { String body = parameters.getString("body"); if (body != null && body.length() > 0) { if (isHTML) { emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body)); } else { emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body); } } } catch (Exception e) { LOG.e("EmailComposer", "Error handling body param: " + e.toString()); } // setting TO recipients try { JSONArray toRecipients = parameters.getJSONArray("toRecipients"); if (toRecipients != null && toRecipients.length() > 0) { String[] to = new String[toRecipients.length()]; for (int i = 0; i < toRecipients.length(); i++) { to[i] = toRecipients.getString(i); } emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, to); } } catch (Exception e) { LOG.e("EmailComposer", "Error handling toRecipients param: " + e.toString()); } // setting CC recipients try { JSONArray ccRecipients = parameters.getJSONArray("ccRecipients"); if (ccRecipients != null && ccRecipients.length() > 0) { String[] cc = new String[ccRecipients.length()]; for (int i = 0; i < ccRecipients.length(); i++) { cc[i] = ccRecipients.getString(i); } emailIntent.putExtra(android.content.Intent.EXTRA_CC, cc); } } catch (Exception e) { LOG.e("EmailComposer", "Error handling ccRecipients param: " + e.toString()); } // setting BCC recipients try { JSONArray bccRecipients = parameters.getJSONArray("bccRecipients"); if (bccRecipients != null && bccRecipients.length() > 0) { String[] bcc = new String[bccRecipients.length()]; for (int i = 0; i < bccRecipients.length(); i++) { bcc[i] = bccRecipients.getString(i); } emailIntent.putExtra(android.content.Intent.EXTRA_BCC, bcc); } } catch (Exception e) { LOG.e("EmailComposer", "Error handling bccRecipients param: " + e.toString()); } // setting attachments try { JSONArray attachments = parameters.getJSONArray("attachments"); if (attachments != null && attachments.length() > 0) { ArrayList<Uri> uris = new ArrayList<Uri>(); // convert from paths to Android friendly Parcelable Uri's for (int i = 0; i < attachments.length(); i++) { try { File file = new File(attachments.getString(i)); if (file.exists()) { Uri uri = Uri.fromFile(file); uris.add(uri); } } catch (Exception e) { LOG.e("EmailComposer", "Error adding an attachment: " + e.toString()); } } if (uris.size() > 0) { emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); } } } catch (Exception e) { LOG.e("EmailComposer", "Error handling attachments param: " + e.toString()); } this.cordova.startActivityForResult(this, emailIntent, 0); }
From source file:com.normalexception.app.rx8club.preferences.Preferences.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getPreferenceManager().setSharedPreferencesName(PreferenceHelper.PREFS_NAME); addPreferencesFromResource(R.xml.preferences); Preference shareLog = (Preference) findPreference("exportLog"); shareLog.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override//from ww w. ja v a 2s . co m public boolean onPreferenceClick(Preference preference) { String user = UserProfile.getInstance().getUsername(); if (user.equals("")) user = "Guest"; // We need to create an intent here for sharing Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); // The intent type is a text type sharingIntent.setType("message/rfc822"); // Add email details sharingIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { getResources().getString(R.string.bug_contact) }); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, "RX8Club.com Log: " + user); // Open the file Uri uri = Uri.fromFile(new File(LogFile.getLogFile())); // Add the file to the intent sharingIntent.putExtra(Intent.EXTRA_STREAM, uri); // Start the intent try { startActivity( Intent.createChooser(sharingIntent, getResources().getString(R.string.sendEmail))); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(MainApplication.getAppContext(), R.string.noEmail, Toast.LENGTH_SHORT).show(); } return true; } }); Preference threadFilter = (Preference) findPreference("threadFilter"); threadFilter.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference arg0) { //startActivity( // new Intent(MainApplication.getAppContext(), ThreadFilterFragment.class)); // Create new fragment and transaction Fragment newFragment = new ThreadFilterFragment(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); // Replace whatever is in the fragment_container view with this fragment, // and add the transaction to the back stack transaction.add(R.id.content_frame, newFragment); transaction.addToBackStack("threadfilter"); // Commit the transaction transaction.commit(); return true; } }); Preference customAdv = (Preference) findPreference("customSig"); customAdv.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference arg0) { SignatureDialog sd = new SignatureDialog(getActivity()); sd.show(); return true; } }); Preference man_fave = (Preference) findPreference("manage_favorites"); man_fave.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference arg0) { if (FavoriteFactory.getInstance().getCount() > 0) { FavoriteDialog fd = new FavoriteDialog(getActivity()); fd.registerToRemove(); fd.show(); } else { notifyError("No Favorites Defined Yet!"); } return true; } }); final Preference cache = (Preference) findPreference("appcache"); cache.setSummary(String.format("Cache Size: %s", SpecialNumberFormatter.readableFileSize((new Cache(getActivity())).getCacheSize()))); cache.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference arg0) { new AsyncTask<Void, String, Void>() { ProgressDialog loadingDialog; @Override protected void onPreExecute() { loadingDialog = ProgressDialog.show(getActivity(), getString(R.string.dialogClearingCache), getString(R.string.pleaseWait), true); } @Override protected Void doInBackground(Void... params) { try { (new FileCache(getActivity())).clear(); } catch (Exception e) { } return null; } @Override protected void onPostExecute(Void result) { try { loadingDialog.dismiss(); loadingDialog = null; } catch (Exception e) { Log.w(TAG, e.getMessage()); } cache.setSummary(String.format("Cache Size: %s", SpecialNumberFormatter .readableFileSize((new Cache(getActivity())).getCacheSize()))); Toast.makeText(getActivity(), R.string.dialogCacheCleared, Toast.LENGTH_SHORT).show(); } }.execute(); return true; } }); Preference rate = (Preference) findPreference("rate"); rate.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference arg0) { try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(WebUrls.marketUrl + MainApplication.APP_PACKAGE))); } catch (ActivityNotFoundException e) { // In the event that the market isn't installed // or is unavailable notifyError("Error Opening Market, Sorry!"); } return true; } }); try { Preference version = (Preference) findPreference("version"); version.setSummary(getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName); } catch (Exception e) { } try { Preference build = (Preference) findPreference("build"); build.setSummary(Integer.toString(getActivity().getPackageManager() .getPackageInfo(getActivity().getPackageName(), 0).versionCode)); } catch (Exception e) { } }
From source file:com.yek.keyboard.ui.SendBugReportUiActivity.java
public void onSendCrashReport(View v) { String[] recipients = new String[] { BuildConfig.CRASH_REPORT_EMAIL_ADDRESS }; Intent sendMail = new Intent(); sendMail.setAction(Intent.ACTION_SEND); sendMail.setType("plain/text"); sendMail.putExtra(Intent.EXTRA_EMAIL, recipients); sendMail.putExtra(Intent.EXTRA_SUBJECT, getText(R.string.ime_crashed_title)); sendMail.putExtra(Intent.EXTRA_TEXT, mCrashReportDetails.crashReportText); try {//from w w w. ja va2 s . c o m Intent sender = Intent.createChooser(sendMail, getString(R.string.ime_crashed_intent_selector_title)); sender.putExtra(Intent.EXTRA_EMAIL, sendMail.getStringArrayExtra(Intent.EXTRA_EMAIL)); sender.putExtra(Intent.EXTRA_SUBJECT, sendMail.getStringExtra(Intent.EXTRA_SUBJECT)); sender.putExtra(Intent.EXTRA_TEXT, mCrashReportDetails.crashReportText); Logger.i(TAG, "Will send crash report using " + sender); startActivity(sender); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getApplicationContext(), "Unable to send bug report via e-mail!", Toast.LENGTH_LONG) .show(); } finish(); }
From source file:info.martinmarinov.dvbdriver.ExceptionDialog.java
private void sendEmail(String[] addresses, String subject, String message) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("*/*"); intent.putExtra(Intent.EXTRA_EMAIL, addresses); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, message); if (intent.resolveActivity(getActivity().getPackageManager()) != null) { startActivity(intent);// w w w. j a va 2 s . c o m } else { Toast.makeText(getContext(), R.string.cannot_send_email, Toast.LENGTH_LONG).show(); } }
From source file:com.anysoftkeyboard.ui.SendBugReportUiActivity.java
public void onSendCrashReport(View v) { String[] recipients = new String[] { BuildConfig.CRASH_REPORT_EMAIL_ADDRESS }; Intent sendMail = new Intent(); sendMail.setAction(Intent.ACTION_SEND); sendMail.setType("plain/text"); sendMail.putExtra(Intent.EXTRA_EMAIL, recipients); sendMail.putExtra(Intent.EXTRA_SUBJECT, getText(R.string.ime_crashed_title)); sendMail.putExtra(Intent.EXTRA_TEXT, mCrashReportDetails.crashReportText); try {// ww w . java2 s.c o m Intent sender = Intent.createChooser(sendMail, getString(R.string.ime_crashed_intent_selector_title)); sender.putExtra(Intent.EXTRA_EMAIL, sendMail.getStringArrayExtra(Intent.EXTRA_EMAIL)); sender.putExtra(Intent.EXTRA_SUBJECT, sendMail.getStringExtra(Intent.EXTRA_SUBJECT)); sender.putExtra(Intent.EXTRA_TEXT, mCrashReportDetails.crashReportText); Log.i(TAG, "Will send crash report using " + sender); startActivity(sender); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getApplicationContext(), "Unable to send bug report via e-mail!", Toast.LENGTH_LONG) .show(); } finish(); }
From source file:com.evo.passwordgenerator.AboutActivity.java
Element getEmailElement() { Element emailElement = new Element(); emailElement.setTitle(this.getString(R.string.emailtext)); emailElement.setIcon(R.drawable.about_screen_email); emailElement.setColor(emailcolor);/*from ww w . j a v a2 s. c om*/ emailElement.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { email }); startActivity(intent); } }); return emailElement; }
From source file:org.totschnig.myexpenses.Utils.java
static void share(Context context, File file, String target) { URI uri = null;/*from w w w .j av a 2 s . c o m*/ try { uri = new URI(target); } catch (URISyntaxException e1) { Toast.makeText(context, context.getString(R.string.ftp_uri_malformed, target), Toast.LENGTH_LONG) .show(); return; } String scheme = uri.getScheme(); if (scheme.equals("ftp")) { new Utils.FtpAsyncTask(context, file, uri).execute(); return; } else if (scheme.equals("mailto")) { final PackageManager packageManager = context.getPackageManager(); final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/qif"); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { uri.getSchemeSpecificPart() }); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "My Expenses export"); emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); if (packageManager.queryIntentActivities(emailIntent, 0).size() == 0) { Toast.makeText(context, R.string.no_app_handling_email_available, Toast.LENGTH_LONG).show(); return; } context.startActivity(emailIntent); } else { Toast.makeText(context, context.getString(R.string.share_scheme_not_supported, target), Toast.LENGTH_LONG).show(); } }
From source file:com.tortel.syslog.dialog.ExceptionDialog.java
private Intent getEmailIntent() { Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "Swarner.dev@gmail.com" }); intent.putExtra(Intent.EXTRA_SUBJECT, "SysLog bug report"); intent.setType("plain/text"); intent.putExtra(Intent.EXTRA_TEXT, getEmailReportBody()); if (!Utils.isHandlerAvailable(getActivity(), intent)) { OhShitDialog dialog = new OhShitDialog(); dialog.setException(result.getException()); dialog.show(getActivity().getSupportFragmentManager(), "ohshit"); this.dismiss(); return null; }//from w w w. j a v a 2 s . co m return intent; }
From source file:com.liato.bankdroid.banking.banks.Coop.java
@Override public Urllib login() throws LoginException, BankException { try {/*from w w w . j a va 2s . c o m*/ LoginPackage lp = preLogin(); response = urlopen.open(lp.getLoginTarget(), lp.getPostData()); if (response.contains("forfarande logga in med ditt personnummer")) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (prefs.getBoolean("debug_mode", false) && prefs.getBoolean("debug_coop_sendmail", false)) { Intent i = new Intent(android.content.Intent.ACTION_SEND); i.setType("plain/text"); i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "android@nullbyte.eu" }); i.putExtra(android.content.Intent.EXTRA_SUBJECT, "Bankdroid - Coop Error"); i.putExtra(android.content.Intent.EXTRA_TEXT, response); context.startActivity(i); } throw new LoginException(res.getText(R.string.invalid_username_password).toString()); } } catch (ClientProtocolException e) { throw new BankException(e.getMessage()); } catch (IOException e) { throw new BankException(e.getMessage()); } return urlopen; }
From source file:in.animeshpathak.nextbus.NextBusMain.java
/** Called when the activity is first started. */ @Override/* w ww. ja va2 s . c o m*/ public void onCreate(Bundle bundle) { Log.d(LOG_TAG, "entering onCreate()"); SettingsActivity.setTheme(this); super.onCreate(bundle); setContentView(R.layout.main); try { busNet = BusNetwork.getInstance(this); } catch (Exception e) { Log.e(LOG_TAG, e.getMessage(), e); return; } // get the button // set handler to launch a processing dialog ImageButton updateButton = (ImageButton) findViewById(R.id.update_button); updateButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { BusLine selectedLine = lineAdapter.getItem(lineSpinner.getSelectedItemPosition()); BusStop selectedStop = stopAdapter.getItem(stopSpinner.getSelectedItemPosition()); getBusTimings(selectedLine, selectedStop); } }); ImageButton feedbackButton = (ImageButton) findViewById(R.id.feedback_button); feedbackButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); // use from live device i.putExtra(Intent.EXTRA_EMAIL, new String[] { Constants.FEEDBACK_EMAIL_ADDRESS }); i.putExtra(Intent.EXTRA_SUBJECT, Constants.FEEDBACK_EMAIL_SUBJECT); i.putExtra(Intent.EXTRA_TEXT, getString(R.string.email_hello)); startActivity(Intent.createChooser(i, getString(R.string.select_email_app))); } }); ImageButton phebusinfoButton = (ImageButton) findViewById(R.id.phebusinfo_button); phebusinfoButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { AlertDialog alertDialog = new AlertDialog.Builder(NextBusMain.this).create(); WebView wv = new WebView(NextBusMain.this); new PhebusNewsLoader(wv, NextBusMain.this).execute(); alertDialog.setView(wv); alertDialog.show(); } }); lineSpinner = (Spinner) findViewById(R.id.line_spinner); lineAdapter = new ArrayAdapter<BusLine>(this, android.R.layout.simple_spinner_item, busNet.getLines()); lineAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); lineSpinner.setAdapter(lineAdapter); stopSpinner = (Spinner) findViewById(R.id.stop_spinner); stopAdapter = new ArrayAdapter<BusStop>(this, android.R.layout.simple_spinner_item); stopAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); stopSpinner.setAdapter(stopAdapter); ImageButton favoriteButton = (ImageButton) findViewById(R.id.favorites_button); favoriteButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { new FavoriteDialog(NextBusMain.this, new OnFavoriteSelectedListener() { @Override public void favoriteSelected(Favorite fav) { BusLine bl = busNet.getLineByName(fav.getLine()); BusStop bs = bl.getFirstStopWithSimilarName(fav.getStop()); if (bl == null || bs == null) { Log.e(LOG_TAG, "Favorite not found!"); return; } updateSpinners(bl, bs); getBusTimings(bl, bs); } }, lineSpinner.getSelectedItem().toString(), stopSpinner.getSelectedItem().toString()); } }); }