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:com.intuitlabs.wear.voiceandchoice.ActionReceiver.java
/** * {@inheritDoc}// www. ja v a2 s . c o m */ @Override public void onReceive(final Context context, final Intent _intent) { /** notificationId used to issue the notification, so we can cancel the notification */ final int notificationId = _intent.getIntExtra(Intent.EXTRA_UID, -1); /** The bundle that was created during the speech recognition process */ final Bundle remoteInput = RemoteInput.getResultsFromIntent(_intent); /* The user's choice, either directly selected or as a speech recognition result. */ final String reply = remoteInput != null ? remoteInput.getCharSequence(AndroidNotification.EXTRA_VOICE_REPLY).toString() : ""; /* The integer value, associated with the command string in the original json document that was used to generate the notification */ @SuppressWarnings("unchecked") final Map<String, Integer> cmdkeys = (Map<String, Integer>) ListStyle.readFromSharedPreference(context); final int selectedId = new PhoneticSearch<>(cmdkeys).match(reply); Log.v(LOG_TAG, "Selection / Speech Recognition result: " + reply); Log.i(LOG_TAG, "Selection / Selected ID " + selectedId); /* Cancel the Notification, which makes it disappear on phone and watch */ final NotificationManager manager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); manager.cancel(notificationId); switch (selectedId) { // Purchase Turbo Tax / Go to Web Page case 0: case 4: final String url = context.getString(R.string.turbotax_url); context.startActivity( new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url)).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); break; // create a calendar Event case 1: case 5: final Calendar cal = Calendar.getInstance(); cal.set(2015, 3, 15); final Intent intent = new Intent(Intent.ACTION_INSERT).setData(CalendarContract.Events.CONTENT_URI) .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, cal.getTimeInMillis()) .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, cal.getTimeInMillis() + 60 * 60 * 1000) .putExtra(CalendarContract.Events.TITLE, context.getString(R.string.turbotax_title)) .putExtra(CalendarContract.Events.DESCRIPTION, context.getString(R.string.turbotax_description)) .putExtra(CalendarContract.Events.EVENT_LOCATION, context.getString(R.string.turbotax_location)) .putExtra(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_BUSY) .putExtra(Intent.EXTRA_EMAIL, context.getString(R.string.turbotax_email)) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); break; // set a reminder case 2: case 6: // todo, set a reminder .. break; // dismiss, do nothing case 3: case 7: default: } }
From source file:fr.free.nrw.commons.settings.SettingsFragment.java
private void sendAppLogsViaEmail() { String appLogs = Utils.getAppLogs(); File appLogsFile = FileUtils.createAndGetAppLogsFile(appLogs); Context applicationContext = getActivity().getApplicationContext(); Uri appLogsFilePath = FileProvider.getUriForFile(getActivity(), applicationContext.getPackageName() + ".provider", appLogsFile); Intent feedbackIntent = new Intent(Intent.ACTION_SEND); feedbackIntent.setType("message/rfc822"); feedbackIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { CommonsApplication.LOGS_PRIVATE_EMAIL }); feedbackIntent.putExtra(Intent.EXTRA_SUBJECT, String.format(CommonsApplication.FEEDBACK_EMAIL_SUBJECT, BuildConfig.VERSION_NAME)); feedbackIntent.putExtra(Intent.EXTRA_STREAM, appLogsFilePath); try {// www.j a v a 2 s.c o m startActivity(feedbackIntent); } catch (ActivityNotFoundException e) { Toast.makeText(getActivity(), R.string.no_email_client, Toast.LENGTH_SHORT).show(); } }
From source file:org.cirrus.mobi.pegel.PegelFragmentsActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.m_refresh: DetailDataFragment df = (DetailDataFragment) getFragmentManager().findFragmentById(R.id.details); df.refresh();/* w ww .ja va 2 s . c om*/ this.pa.trackEvent("PegelDataView", "refresh", "refresh3", 1); return true; case R.id.m_feedback: final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("message/rfc822"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "dominik.helleberg@googlemail.com" }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Pegel-Online Feedback"); this.pa.trackEvent("PegelDataView", "feedback", "feedback3", 1); startActivity(Intent.createChooser(emailIntent, "Email senden...")); return true; case R.id.m_about: showDialog(DIALOG_ABOUT); this.pa.trackEvent("PegelDataView", "about", "about3", 1); return true; case R.id.m_donate: Intent i = new Intent(this, DonateActivity.class); this.pa.trackEvent("PegelDataView", "donate", "donate", 1); startActivity(i); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.yangtsaosoftware.pebblemessenger.activities.SetupFragment.java
private void send_report_to_author() { Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setData(Uri.parse("mailto:")); emailIntent.setType("text/plain"); String[] TO = { Constants.AUTHOR_EMAIL }; emailIntent.putExtra(Intent.EXTRA_EMAIL, TO); emailIntent.putExtra(Intent.EXTRA_SUBJECT, _context.getString(R.string.setup_report_subject)); emailIntent.putExtra(Intent.EXTRA_TEXT, textInfo.getText()); startActivity(Intent.createChooser(emailIntent, _context.getString(R.string.setup_send_mail))); }
From source file:edu.mecc.race2ged.helpers.Utils.java
/** * Send an email with supplied address, subject, and content. * @param emailAddress To: Email Address * @param emailSubject Email Subject/*from w ww. j av a 2s . c o m*/ * @param emailBody Email Body Content */ public static void sendEmail(Context context, String emailAddress, String emailSubject, String emailBody) { try { final Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setType("plain/html"); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { emailAddress }); emailIntent.putExtra(Intent.EXTRA_SUBJECT, emailSubject); emailIntent.putExtra(Intent.EXTRA_TEXT, emailBody); context.startActivity(Intent.createChooser(emailIntent, "Select your Email App:")); } catch (Exception e) { Log.e(context.getClass().getSimpleName(), "Error sending email. Email app installed? - " + e.getMessage()); } }
From source file:net.frakbot.FWeather.util.FeedbackService.java
/** * Sends a feedback email (fallback for when the Android feedback mechanism * doesn't work or isn't available).// w w w . ja va2s .c o m */ private void sendFeedbackEmail() { Intent email = new Intent(Intent.ACTION_SEND); email.putExtra(Intent.EXTRA_EMAIL, new String[] { "frakbot+fweather@gmail.com" }); email.putExtra(Intent.EXTRA_SUBJECT, "[FEEDBACK] " + getString(R.string.app_name)); email.setType("message/rfc822"); final File logFile = collectLogcat(); if (logFile != null && logFile.exists()) { email.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(logFile)); email.putExtra(Intent.EXTRA_TEXT, generateFeedbackBody()); } else { email.putExtra(Intent.EXTRA_TEXT, "\n\nCouldn't attach logcat\n\n" + generateFeedbackBody()); } try { FLog.i(TAG, "Sending feedback email"); startActivity(Intent.createChooser(email, getString(R.string.feedback_send_chooser_title)) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); stopForeground(true); } catch (Exception e) { Toast.makeText(this, getString(R.string.toast_feedback_mail_error), Toast.LENGTH_LONG).show(); FLog.e(TAG, "Unable to send the feedback email", e); stopForeground(true); } }
From source file:saschpe.birthdays.fragment.SocialFragment.java
/** * Called immediately after {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)} * has returned, but before any saved state has been restored in to the view. * This gives subclasses a chance to initialize themselves once * they know their view hierarchy has been completely created. The fragment's * view hierarchy is not however attached to its parent at this point. * * @param view The View returned by {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}. * @param savedInstanceState If non-null, this fragment is being re-constructed *//*from w ww . j ava2 s. com*/ @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); provideFeedback.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String subject = getString(R.string.feedback_mail_subject_template, getString(R.string.app_name)); Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", SUPPORT_EMAIL_ADDRESS[0], null)) .putExtra(Intent.EXTRA_SUBJECT, subject).putExtra(Intent.EXTRA_TEXT, "") .putExtra(Intent.EXTRA_EMAIL, SUPPORT_EMAIL_ADDRESS); startActivity(Intent.createChooser(emailIntent, view.getContext().getString(R.string.send_email))); } }); followTwitter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?screen_name=" + TWITTER_NAME))); } catch (ActivityNotFoundException e) { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/#!/" + TWITTER_NAME))); } } }); rateOnPlayStore.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // To count with Play market back stack, After pressing back button, // to taken back to our application, we need to add following flags to intent. int flags = Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK; if (Build.VERSION.SDK_INT >= 21) { flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT; } else { //noinspection deprecation flags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET; } Intent goToMarket = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName)) .addFlags(flags); try { startActivity(goToMarket); } catch (ActivityNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + packageName))); } } }); recommendToFriend.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String subject = getString(R.string.get_app_template, getString(R.string.app_name)); String body = Uri.parse("http://play.google.com/store/apps/details?id=" + packageName).toString(); Intent sharingIntent = new Intent(Intent.ACTION_SEND).setType("text/plain") .putExtra(Intent.EXTRA_SUBJECT, subject).putExtra(Intent.EXTRA_TEXT, body); startActivity(Intent.createChooser(sharingIntent, view.getContext().getString(R.string.share_via))); } }); forkOnGithub.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(Intent.ACTION_VIEW) .setData(Uri.parse("https://github.com/saschpe/BirthdayCalendar"))); } }); }
From source file:com.android.messaging.datamodel.media.VCardResourceEntry.java
private static List<VCardResourceEntryDestinationItem> getContactInfoFromVCardEntry(final VCardEntry vcard) { final Resources resources = Factory.get().getApplicationContext().getResources(); final List<VCardResourceEntry.VCardResourceEntryDestinationItem> retList = new ArrayList<VCardResourceEntry.VCardResourceEntryDestinationItem>(); if (vcard.getPhoneList() != null) { for (final PhoneData phone : vcard.getPhoneList()) { final Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:" + phone.getNumber())); retList.add(new VCardResourceEntryDestinationItem(phone.getNumber(), Phone.getTypeLabel(resources, phone.getType(), phone.getLabel()).toString(), intent)); }/* www. jav a 2s . com*/ } if (vcard.getEmailList() != null) { for (final EmailData email : vcard.getEmailList()) { final Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:")); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { email.getAddress() }); retList.add(new VCardResourceEntryDestinationItem(email.getAddress(), Phone.getTypeLabel(resources, email.getType(), email.getLabel()).toString(), intent)); } } if (vcard.getPostalList() != null) { for (final PostalData postalData : vcard.getPostalList()) { String type; try { type = resources.getStringArray(android.R.array.postalAddressTypes)[postalData.getType() - 1]; } catch (final NotFoundException ex) { type = resources.getStringArray(android.R.array.postalAddressTypes)[2]; } catch (final Exception e) { LogUtil.e(LogUtil.BUGLE_TAG, "createContactItem postal Exception:" + e); type = resources.getStringArray(android.R.array.postalAddressTypes)[2]; } Intent intent = new Intent(Intent.ACTION_VIEW); final String address = formatAddress(postalData); try { intent.setData(Uri.parse("geo:0,0?q=" + URLEncoder.encode(address, "UTF-8"))); } catch (UnsupportedEncodingException e) { intent = null; } retList.add(new VCardResourceEntryDestinationItem(address, type, intent)); } } if (vcard.getImList() != null) { for (final ImData imData : vcard.getImList()) { String type = null; try { type = resources.getString(Im.getProtocolLabelResource(imData.getProtocol())); } catch (final NotFoundException ex) { // Do nothing since this implies an empty label. } retList.add(new VCardResourceEntryDestinationItem(imData.getAddress(), type, null)); } } if (vcard.getOrganizationList() != null) { for (final OrganizationData organtization : vcard.getOrganizationList()) { String type = null; try { type = resources.getString(Organization.getTypeLabelResource(organtization.getType())); } catch (final NotFoundException ex) { //set other kind as "other" type = resources.getStringArray(android.R.array.organizationTypes)[1]; } catch (final Exception e) { LogUtil.e(LogUtil.BUGLE_TAG, "createContactItem org Exception:" + e); type = resources.getStringArray(android.R.array.organizationTypes)[1]; } retList.add(new VCardResourceEntryDestinationItem(organtization.getOrganizationName(), type, null)); } } if (vcard.getWebsiteList() != null) { for (final WebsiteData web : vcard.getWebsiteList()) { if (web != null && TextUtils.isGraphic(web.getWebsite())) { String website = web.getWebsite(); if (!website.startsWith("http://") && !website.startsWith("https://")) { // Prefix required for parsing to end up with a scheme and result in // navigation website = "http://" + website; } final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(website)); retList.add(new VCardResourceEntryDestinationItem(web.getWebsite(), null, intent)); } } } if (vcard.getBirthday() != null) { final String birthday = vcard.getBirthday(); if (TextUtils.isGraphic(birthday)) { retList.add(new VCardResourceEntryDestinationItem(birthday, resources.getString(R.string.vcard_detail_birthday_label), null)); } } if (vcard.getNotes() != null) { for (final NoteData note : vcard.getNotes()) { final ArrayMap<String, String> curChildMap = new ArrayMap<String, String>(); if (TextUtils.isGraphic(note.getNote())) { retList.add(new VCardResourceEntryDestinationItem(note.getNote(), resources.getString(R.string.vcard_detail_notes_label), null)); } } } return retList; }
From source file:com.infamous.site.activity.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.more: return true; case R.id.shareButton: Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.app_link)); startActivity(Intent.createChooser(shareIntent, "Share Via")); break;/*w w w . j a v a2s .c om*/ case R.id.rateButton: Intent rate = new Intent(Intent.ACTION_VIEW) .setData(Uri.parse(getResources().getString(R.string.market_rate))); startActivity(rate); break; case R.id.emailButton: Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { getResources().getString(R.string.email_address) }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getText(R.string.email_subject)); emailIntent.setType("plain/text"); startActivity(Intent.createChooser(emailIntent, "Contact Developer")); break; case R.id.aboutButton: Intent about = new Intent(MainActivity.this, AboutDev.class); startActivity(about); break; case R.id.aboutButton2: Intent about2 = new Intent(MainActivity.this, AboutDev2.class); startActivity(about2); break; case R.id.gplusButton: Intent gpCommunity = new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://goo.gl/VrsA4Q")); startActivity(gpCommunity); break; } return true; }
From source file:cz.maresmar.sfm.app.SfmApp.java
private void sendFeedback(Context context, String subject) { Timber.i("Device %s (%s) on SDK %d", Build.DEVICE, Build.MANUFACTURER, Build.VERSION.SDK_INT); File logFile = getLogFile();//from w w w . j av a2 s . com Uri logUri = FileProvider.getUriForFile(this, "cz.maresmar.sfm.FileProvider", logFile); Intent emailIntent = new Intent(Intent.ACTION_SENDTO); emailIntent.setData(Uri.parse("mailto:")); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "mmrmartin+dev" + '@' + "gmail.com" }); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "[sfm] " + subject); emailIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.feedback_mail_text)); emailIntent.putExtra(Intent.EXTRA_STREAM, logUri); emailIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); List<ResolveInfo> resInfoList = getPackageManager().queryIntentActivities(emailIntent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; context.grantUriPermission(packageName, logUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); } context.startActivity( Intent.createChooser(emailIntent, getString(R.string.feedback_choose_email_app_dialog))); }