List of usage examples for android.content Intent ACTION_SENDTO
String ACTION_SENDTO
To view the source code for android.content Intent ACTION_SENDTO.
Click Source Link
From source file:com.android.contacts.common.ContactsUtils.java
private static Intent getCustomImIntent(ImDataItem im, int protocol) { String host = im.getCustomProtocol(); final String data = im.getData(); if (TextUtils.isEmpty(data)) { return null; }// w ww . j a v a 2s.co m if (protocol != Im.PROTOCOL_CUSTOM) { // Try bringing in a well-known host for specific protocols host = ContactsUtils.lookupProviderNameFromId(protocol); } if (TextUtils.isEmpty(host)) { return null; } final String authority = host.toLowerCase(); final Uri imUri = new Uri.Builder().scheme(SCHEME_IMTO).authority(authority).appendPath(data).build(); final Intent intent = new Intent(Intent.ACTION_SENDTO, imUri); return intent; }
From source file:com.appsol.sharewithcontact.ui.ContactsListActivity.java
/** * This interface callback lets the main contacts list fragment notify * this activity that a contact has been selected. * * @param contactUri The contact Uri to the selected contact. *//*from www . j a va 2s . c o m*/ @Override public void onContactSelected(Uri contactUri) { if (isTwoPaneLayout && mContactDetailFragment != null) { // If two pane layout then update the detail fragment to show the selected contact mContactDetailFragment.setContact(contactUri); } else { // Otherwise single pane layout, start a new ContactDetailActivity with // the contact Uri /* Intent intent = new Intent(this, ContactDetailActivity.class); intent.setData(contactUri); startActivity(intent); */ String id, name = "def", phone, hasPhone = "000"; int idx; Cursor cursor = getContentResolver().query(contactUri, null, null, null, null); if (cursor.moveToFirst()) { idx = cursor.getColumnIndex(ContactsContract.Contacts._ID); id = cursor.getString(idx); cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = " + id, null, null); if (cursor.moveToFirst()) { int colIdx = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER); hasPhone = cursor.getString(colIdx); } idx = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME); name = cursor.getString(idx); } // idx = cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER); //hasPhone = cursor.getString(idx); Uri uri = Uri.parse("smsto:" + hasPhone); Intent it = new Intent(Intent.ACTION_SENDTO, uri); String sharemessage = "" + "I am using Nsore Devotional and it helps me daily in \n" + "my life with God, keeps me in touch with the word, my Church etc.\n" + " Download it now from: \n " + Connector.parentURL; it.putExtra("sms_body", sharemessage); startActivity(it); } }
From source file:com.artemchep.horario.ui.dialogs.FeedbackDialog.java
private boolean send(@NonNull CharSequence title, @NonNull CharSequence body) { Activity activity = getActivity();//from w w w .ja va 2 s . c o m String[] recipients = { Binfo.SUPPORT_EMAIL }; Intent intent = new Intent().putExtra(Intent.EXTRA_EMAIL, recipients).putExtra(Intent.EXTRA_SUBJECT, title) .putExtra(Intent.EXTRA_TEXT, body); intent.setAction(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:")); // only email apps should handle it try { startActivity(intent); return true; } catch (ActivityNotFoundException e) { Toasty.error(activity, getString(R.string.feedback_error_no_app), Toast.LENGTH_LONG).show(); return false; } }
From source file:im.delight.android.commons.Social.java
/** * Displays an application chooser and composes the described email using the selected application * * @param recipientEmail the recipient's email address * @param subjectText the subject line of the message * @param bodyText the body text of the message * @param captionRes a string resource ID for the title of the application chooser's window * @param restrictToPackage an application's package name to restricted the selection to * @param context a context reference//from www. jav a 2 s.c om * @throws Exception if there was an error trying to launch the email application */ public static void sendMail(final String recipientEmail, final String subjectText, final String bodyText, final int captionRes, final String restrictToPackage, final Context context) throws Exception { final String uriString = "mailto:" + Uri.encode(recipientEmail) + "?subject=" + Uri.encode(subjectText) + "&body=" + Uri.encode(bodyText); final Uri uri = Uri.parse(uriString); final Intent emailIntent = new Intent(Intent.ACTION_SENDTO); emailIntent.setData(uri); if (restrictToPackage != null && restrictToPackage.length() > 0) { emailIntent.setPackage(restrictToPackage); if (context != null) { // launch the target app directly context.startActivity(emailIntent); } } else { if (context != null) { // offer a selection of all applications that can handle the email Intent context.startActivity(Intent.createChooser(emailIntent, context.getString(captionRes))); } } }
From source file:org.hawkular.client.android.activity.MainActivity.java
@Override public boolean onNavigationItemSelected(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.menu_favourites: showFavourites();/*www. j a va 2 s.c o m*/ menuItem.setChecked(true); break; case R.id.menu_alerts: showAlerts(); menuItem.setChecked(true); break; case R.id.menu_feedback: String feedbackAddress = getString(R.string.feedback_address); String feedbackSubject = getString(R.string.feedback_subject); String feedbackUri = String.format("mailto:%s?subject=%s", feedbackAddress, feedbackSubject); Intent feedbackIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse(feedbackUri)); startActivity(feedbackIntent); break; case R.id.menu_explorer: startActivity(new Intent(getApplicationContext(), InventoryExplorerActivity.class)); break; case R.id.menu_logout: BackendClient.of(this).deauthorize(getApplicationContext()); startActivity(new Intent(getApplicationContext(), LoginActivity.class)); break; default: break; } currentNavigationId = menuItem.getItemId(); drawer.closeDrawers(); return true; }
From source file:fr.tvbarthel.apps.cameracolorpicker.activities.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { final int itemId = item.getItemId(); boolean handled; switch (itemId) { case R.id.menu_main_action_licenses: handled = true;// w w w .j a va 2 s.c o m final Intent intent = new Intent(this, LicenseActivity.class); startActivity(intent); break; case R.id.menu_main_action_about: handled = true; AboutDialogFragment.newInstance().show(getSupportFragmentManager(), null); break; case R.id.menu_main_action_contact_us: handled = true; final String uriString = getString(R.string.contact_us_uri, Uri.encode(getString(R.string.contact_us_email)), Uri.encode(getString(R.string.contact_us_default_subject))); final Uri mailToUri = Uri.parse(uriString); final Intent sendToIntent = new Intent(Intent.ACTION_SENDTO); sendToIntent.setData(mailToUri); startActivity(sendToIntent); break; default: handled = mMainActivityFlavor.onOptionsItemSelected(item); if (!handled) { handled = super.onOptionsItemSelected(item); } } return handled; }
From source file:com.tlongdev.bktf.ui.activity.AboutActivity.java
/** * Shows the simplified settings UI if the device configuration if the * device configuration dictates that a simplified, single-pane UI should be * shown./*from w w w . j a v a 2 s. c om*/ */ private void setupSimplePreferencesScreen() { // Add 'general' preferences. addPreferencesFromResource(R.xml.pref_about); PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this); // Bind the summaries of EditText/List/Dialog/Ringtone preferences to // their values. When their values change, their summaries are updated // to reflect the new value, per the Android Design guidelines. findPreference(getString(R.string.pref_title_feedback)) .setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { //Start an email intent with my email as the target Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "dev@tlongdev.com", null)); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(Intent.createChooser(intent, getString(R.string.message_send_email))); } return true; } }); findPreference(getString(R.string.pref_title_rate)) .setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { //Open the Play Store page of the app final String appPackageName = getPackageName(); try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); } catch (android.content.ActivityNotFoundException e) { //Play store is not present on the phone. Open the browser CustomTabActivityHelper.openCustomTab(AboutActivity.this, new CustomTabsIntent.Builder().build(), Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName), new WebViewFallback()); } return true; } }); //Set the version name to the summary, so I don't have to change it manually every goddamn //update findPreference(getString(R.string.pref_title_version)).setSummary(BuildConfig.VERSION_NAME); }
From source file:com.hataskrau.ui.issue.detailed.DetailedIssueActivity.java
@Override public void onClick(View v) { Intent emailIntent = new Intent(Intent.ACTION_SENDTO); emailIntent.putExtra(Intent.EXTRA_EMAIL, "RAYLYAN.E.V@MAIL.COM"); sendBroadcast(emailIntent);/*from w w w .j a v a 2 s. c o m*/ }
From source file:es.esy.vivekrajendran.news.MainActivity.java
/** * This method will be called whenever overflow options menu item is clicked. * @param item represents clicked overflow item. * @return always return true./*from w w w .j a v a2 s .c o m*/ */ @SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.nav_gallery: startActivity(new Intent(MainActivity.this, GalleryActivity.class)); break; case R.id.nav_settings: break; case R.id.nav_developer: //getting fragmenttransaction object then show Dialog fragment FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fm_dev = fragmentManager.beginTransaction(); DevDialog dev = new DevDialog(); dev.setContext(getApplicationContext()); //dev.show(fm_dev, "dev"); break; case R.id.nav_share: //initializing sharecompat to share the app ShareCompat.IntentBuilder.from(MainActivity.this).createChooserIntent().setData(Uri.parse("mailto:")); break; case R.id.nav_feedback: //initializing intent to share feedback Intent feedbackIntent = new Intent(); feedbackIntent.setAction(Intent.ACTION_SENDTO); feedbackIntent.setData(Uri.parse("mailto:vivekrajendrn@gmail.com")); startActivity(Intent.createChooser(feedbackIntent, "Send feedback with")); break; case R.id.nav_logout: //sinning out current user mFirebaseAuth.signOut(); break; } //Initializing drawer layout DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:ir.rasen.charsoo.view.fragment.FragmentUserRegisterOfferFriendSMS.java
private void doSendSMS() { if (selectedContactsToInvite.size() > 0) { if (selectedContactsToInvite.size() <= remainingSMSCount) { // TODO: SEND SMS REQUEST TO SERVER } else {/*from w w w .ja v a2 s .co m*/ String numbers; ArrayList<Integer> keys = new ArrayList<>(selectedContactsToInvite.keySet()); numbers = selectedContactsToInvite.get(keys.get(0)).contactData; for (int i = 1; i < keys.size(); i++) { numbers += ";"; numbers += selectedContactsToInvite.get(keys.get(i)).contactData; } Intent smsIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + numbers)); smsIntent.putExtra("sms_body", "Body of Message"); startActivity(smsIntent); } } }