Example usage for android.content Intent ACTION_SENDTO

List of usage examples for android.content Intent ACTION_SENDTO

Introduction

In this page you can find the example usage for android.content Intent ACTION_SENDTO.

Prototype

String ACTION_SENDTO

To view the source code for android.content Intent ACTION_SENDTO.

Click Source Link

Document

Activity Action: Send a message to someone specified by the data.

Usage

From source file:se.johan.wendler.fragment.AboutFragment.java

/**
 * Called when a list item is clicked./*from ww w . j  av  a2 s  .co  m*/
 */
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    switch (position) {
    case 0:
        ChangelogDialog.newInstance().show(getActivity().getSupportFragmentManager(), ChangelogDialog.TAG);
        break;
    case 1:
        Intent sendIntent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", "lolbolljohan@gmail.com", null));

        sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.wendlerized) + " "
                + Utils.getCurrentAppVersion(getActivity()) + " feedback");
        startActivity(Intent.createChooser(sendIntent, getString(R.string.send_email_title)));
        break;
    case 2:
        LicensesDialogFragment.newInstance(R.raw.notices, false).show(getActivity().getSupportFragmentManager(),
                null);
        break;
    }
}

From source file:library.artaris.cn.library.utils.SystemUtils.java

/**
 * ?/* www.j  a  v  a 2s  .c  om*/
 * @param mContext
 * @param mailID
 */
public static void sendMail(Context mContext, String mailID) {
    Uri uri = Uri.parse("mailto:" + mailID);
    mContext.startActivity(new Intent(Intent.ACTION_SENDTO, uri));
}

From source file:de.westnordost.streetcomplete.about.AboutFragment.java

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    addPreferencesFromResource(R.xml.about);

    findPreference("version").setSummary(BuildConfig.VERSION_NAME);

    findPreference("license").setOnPreferenceClickListener(preference -> {
        Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("https://www.gnu.org/licenses/gpl-3.0.html"));
        startActivity(browserIntent);/*  w  w  w  .jav a2  s  .c o m*/
        return true;
    });

    findPreference("authors").setOnPreferenceClickListener(preference -> {
        getFragmentActivity().setCurrentFragment(new CreditsFragment());
        return true;
    });

    findPreference("privacy").setOnPreferenceClickListener(preference -> {
        Fragment f = ShowHtmlFragment.create(
                getResources().getString(R.string.privacy_html) + getString(R.string.privacy_html_tileserver)
                        + getString(R.string.privacy_html_third_party_quest_sources)
                        + getString(R.string.privacy_html_image_upload2),
                R.string.about_title_privacy_statement);
        getFragmentActivity().setCurrentFragment(f);
        return true;
    });

    findPreference("repository").setOnPreferenceClickListener(preference -> {
        Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("https://github.com/westnordost/StreetComplete/"));
        startActivity(browserIntent);
        return true;
    });

    findPreference("report_error").setOnPreferenceClickListener(preference -> {
        Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("https://github.com/westnordost/StreetComplete/issues/"));
        startActivity(browserIntent);
        return true;
    });

    findPreference("email_feedback").setOnPreferenceClickListener(preference -> {
        Intent intent = new Intent(Intent.ACTION_SENDTO);
        intent.setData(Uri.parse("mailto:"));
        intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "osm@westnordost.de" });
        intent.putExtra(Intent.EXTRA_SUBJECT, ApplicationConstants.USER_AGENT + " Feedback");
        if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
            startActivity(intent);
            return true;
        }
        return false;
    });
}

From source file:com.nexus.nsnik.randomno.view.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int menuItemId = item.getItemId();
    switch (menuItemId) {
    case R.id.menuSettings:
        startActivityForResult(new Intent(MainActivity.this, PreferenceActivity.class),
                PREFERENCE_REQUEST_CODE);
        break;/*  w w w  . j a  va2 s. c  om*/
    case R.id.menuAbout:
        new AboutDialogFragment().show(getSupportFragmentManager(), "AboutDialog");
        break;
    case R.id.menuFeedback:
        Intent sentEmail = new Intent(Intent.ACTION_SENDTO);
        sentEmail.setData(Uri.parse("mailto:"));
        sentEmail.putExtra(Intent.EXTRA_EMAIL, getResources().getString(R.string.developerEmailAddress));
        sentEmail.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.emailSubject));
        if (sentEmail.resolveActivity(getPackageManager()) != null)
            startActivity(sentEmail);
        break;
    }
    return true;
}

From source file:com.pasta.mensadd.fragments.ImprintFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.feedback:
        Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", "julianctni@gmail.com", null));
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "feedback mensaDD");
        startActivity(Intent.createChooser(emailIntent, getString(R.string.send_feedback_mail)));
        return true;
    default:// ww  w.  j a v a  2 s . c  o  m
        return super.onOptionsItemSelected(item);
    }
}

From source file:spit.matrix2017.Fragments.ContactUsFragment.java

@Nullable
@Override//from ww  w.  j  a v a  2s.  c  o m
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_contactus, container, false);

    findOnMap = (Button) view.findViewById(R.id.findOnMap);
    visitWebsite = (Button) view.findViewById(R.id.visitWebsite);
    contact_one_Button = (AppCompatImageButton) view.findViewById(R.id.contact_us_call_one);
    contact_two_Button = (AppCompatImageButton) view.findViewById(R.id.contact_us_call_two);
    save_one_Button = (AppCompatImageButton) view.findViewById(R.id.contact_us_save_one);
    save_two_Button = (AppCompatImageButton) view.findViewById(R.id.contact_us_save_two);
    emailId_matrix_TextView = (TextView) view.findViewById(R.id.emailId_matrix_TextView);

    emailId_matrix_TextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String to = "principal@spit.ac.in";
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_SENDTO);
            intent.setType("text/plain");
            intent.setData(Uri.parse("mailto:" + to));
            intent.putExtra(Intent.EXTRA_EMAIL, to);
            try {
                startActivity(Intent.createChooser(intent, "Send Email"));
            } catch (Exception e) {
                Toast.makeText(getActivity(), e.getStackTrace().toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });

    visitWebsite.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.spit.ac.in")));
        }
    });

    findOnMap.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Uri uri = Uri
                    .parse("http://maps.google.com/maps?q=" + Uri.encode(getString(R.string.college_name)));
            Intent mapIntent = new Intent(Intent.ACTION_VIEW, uri);
            mapIntent.setPackage("com.google.android.apps.maps");
            try {
                startActivity(mapIntent);
            } catch (ActivityNotFoundException ex) {
                try {
                    Intent newIntent = new Intent(Intent.ACTION_VIEW, uri);
                    startActivity(newIntent);
                } catch (ActivityNotFoundException innerEx) {
                    Toast.makeText(getContext(), "Please install a maps application", Toast.LENGTH_LONG).show();
                }
            }
        }
    });

    View.OnClickListener dialerOnClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_DIAL);
            switch (v.getId()) {
            case R.id.contact_us_call_one:
                intent.setData(Uri.parse("tel:" + "02226707440"));
                break;
            case R.id.contact_us_call_two:
                intent.setData(Uri.parse("tel:" + "02226287250"));
                break;
            }
            startActivity(intent);
        }
    };
    contact_one_Button.setOnClickListener(dialerOnClickListener);
    contact_two_Button.setOnClickListener(dialerOnClickListener);

    View.OnClickListener saveOnClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_INSERT, ContactsContract.Contacts.CONTENT_URI);
            switch (v.getId()) {
            case R.id.contact_us_save_one:
                intent.putExtra(ContactsContract.Intents.Insert.NAME, "S.P.I.T.");
                intent.putExtra(ContactsContract.Intents.Insert.PHONE, "02226707440");
                break;
            case R.id.contact_us_save_two:
                intent.putExtra(ContactsContract.Intents.Insert.NAME, "S.P.I.T.");
                intent.putExtra(ContactsContract.Intents.Insert.PHONE, "02226708520");
                break;
            }
            startActivity(intent);
        }
    };
    save_one_Button.setOnClickListener(saveOnClickListener);
    save_two_Button.setOnClickListener(saveOnClickListener);

    return view;
}

From source file:com.king.base.util.SystemUtils.java

/**
 * ??//  w w  w. j a va 2  s. c o m
 *
 * @param context
 * @param phoneNumber
 */
public static void sendSMS(Context context, String phoneNumber) {

    Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(String.format("smsto:%s", phoneNumber)));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    context.startActivity(intent);
}

From source file:com.karthikb351.vitinfo2.fragment.AboutFragment.java

void sendFeedBack(View view) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setType(Constants.INTENT_TYPE_PLAIN);
    intent.setData(Uri.parse(Constants.FEEDBACK_EMAIL_LINK));
    intent.putExtra(Intent.EXTRA_SUBJECT, Constants.FEEDBACK_EMAIL_SUBJECT);
    startActivity(intent);//from ww w.  ja  v a2 s.  c  om
}

From source file:com.emartynov.android.app.urlsetter.android.ui.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.action_about) {
        startActivity(new Intent(this, AboutActivity.class));
        return true;
    } else if (item.getItemId() == R.id.action_feedback) {
        Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", "bijdorpstudio@gmail.com", null));
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.feedback_subject));
        startActivity(Intent.createChooser(emailIntent, getString(R.string.action_feedback)));
        return true;
    } else if (item.getItemId() == R.id.action_resolve_link) {
        FragmentManager fm = getSupportFragmentManager();
        EnterShortenedUrlFragment userInputDialog = new EnterShortenedUrlFragment();
        userInputDialog.show(fm, null);/*from ww w  . java 2s  . c o m*/

        return true;
    } else {
        return super.onOptionsItemSelected(item);
    }
}

From source file:fr.bmartel.fadecandy.menu.MenuUtils.java

/**
 * Execute actions according to selected menu item
 *
 * @param menuItem MenuItem object//  w ww .  j  a va 2s  .  c  o m
 * @param mDrawer  navigation drawer
 * @param context  android context
 */
public static void selectDrawerItem(MenuItem menuItem, DrawerLayout mDrawer, Context context,
        final IFc fcActivity) {

    switch (menuItem.getItemId()) {
    case R.id.server_status: {
        fcActivity.switchServerStatus();
        break;
    }
    case R.id.server_config: {
        if (fcActivity != null) {
            ConfigurationDialog dialog = new ConfigurationDialog(fcActivity);
            fcActivity.setCurrentDialog(dialog);
            dialog.show();
        }
        break;
    }
    case R.id.ledstrip_config: {
        if (fcActivity != null) {
            LedStripConfigurationDialog dialog = new LedStripConfigurationDialog(fcActivity);
            fcActivity.setCurrentDialog(dialog);
            dialog.show();
        }
        break;
    }
    case R.id.open_source_components: {
        OpenSourceItemsDialog dialog = new OpenSourceItemsDialog(context);
        fcActivity.setCurrentDialog(dialog);
        dialog.show();
        break;
    }
    case R.id.rate_app: {
        context.startActivity(new Intent(Intent.ACTION_VIEW,
                Uri.parse("market://details?id=" + context.getApplicationContext().getPackageName())));
        break;
    }
    case R.id.about_app: {
        AboutDialog dialog = new AboutDialog(context);
        fcActivity.setCurrentDialog(dialog);
        dialog.show();
        break;
    }
    case R.id.report_bugs: {
        Intent intent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", context.getResources().getString(R.string.developper_mail), null));
        intent.putExtra(Intent.EXTRA_SUBJECT, context.getResources().getString(R.string.issue_object));
        intent.putExtra(Intent.EXTRA_TEXT, context.getResources().getString(R.string.issue_message));
        context.startActivity(
                Intent.createChooser(intent, context.getResources().getString(R.string.issue_title)));
        break;
    }
    case R.id.service_config: {

        CharSequence[] array = { "persistent", "non persistent" };

        int indexCheck = 0;
        if (fcActivity.getServiceType() == ServiceType.NON_PERSISTENT_SERVICE) {
            indexCheck = 1;
        }

        Dialog dialog = new AlertDialog.Builder(context).setSingleChoiceItems(array, indexCheck, null)
                .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        dialog.dismiss();
                        int selectedPosition = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
                        if (selectedPosition == 1) {
                            fcActivity.setServiceType(ServiceType.NON_PERSISTENT_SERVICE);
                        } else {
                            fcActivity.setServiceType(ServiceType.PERSISTENT_SERVICE);
                        }
                    }
                }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        dialog.dismiss();
                    }
                }).show();
        fcActivity.setCurrentDialog(dialog);

        break;
    }
    }
    mDrawer.closeDrawers();
}