Example usage for android.content Intent EXTRA_EMAIL

List of usage examples for android.content Intent EXTRA_EMAIL

Introduction

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

Prototype

String EXTRA_EMAIL

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

Click Source Link

Document

A String[] holding e-mail addresses that should be delivered to.

Usage

From source file:com.twolinessoftware.android.mobileresume.fragment.ContactViewFragment.java

@OnClick(R.id.card_contact_email)
public void onSendEmail(View view) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:"));
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "john@2linessoftware.com" });
    intent.putExtra(Intent.EXTRA_SUBJECT, "Feedback");

    startActivity(Intent.createChooser(intent, "Email via..."));
}

From source file:com.sbgapps.scoreit.fragments.InfoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_info, container, false);

    PackageManager pm = getActivity().getPackageManager();
    String packageName = getActivity().getPackageName();
    String version;/*from   w w w .  ja v a2s .  co m*/
    try {
        PackageInfo info = pm.getPackageInfo(packageName, 0);
        version = info.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        version = VERSION_UNAVAILABLE;
    }
    version = getActivity().getString(R.string.app_name) + " " + version;
    TextView nameAndVersionView = (TextView) view.findViewById(R.id.version);
    nameAndVersionView.setText(version);

    Button btn;

    btn = (Button) view.findViewById(R.id.btn_contact);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("message/rfc822");
            intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "stephane@baiget.fr" });
            intent.putExtra(Intent.EXTRA_SUBJECT, "Score It");
            try {
                startActivity(intent);
            } catch (ActivityNotFoundException e) {
            }
        }
    });

    btn = (Button) view.findViewById(R.id.btn_rate);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Uri uri = Uri.parse("market://details?id=" + getActivity().getPackageName());
            Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
            try {
                startActivity(goToMarket);
            } catch (ActivityNotFoundException e) {
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(
                        "http://play.google.com/store/apps/details?id=" + getActivity().getPackageName())));
            }
        }
    });

    btn = (Button) view.findViewById(R.id.btn_share);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.putExtra(Intent.EXTRA_TEXT,
                    "http://play.google.com/store/apps/details?id=" + getActivity().getPackageName());
            startActivity(intent);
        }
    });

    btn = (Button) view.findViewById(R.id.btn_community);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://plus.google.com/u/0/communities/111590957716888215587"));
            startActivity(intent);
        }
    });

    btn = (Button) view.findViewById(R.id.btn_translate);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://crowdin.net/project/score-it"));
            startActivity(intent);
        }
    });
    return view;
}

From source file:io.github.importre.android.chromeadb.InfoFragment.java

private void sendFeedback() {
    FragmentActivity activity = getActivity();
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType(activity.getString(R.string.feedback_type));
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { activity.getString(R.string.chromeadb_gmail) });
    intent.putExtra(Intent.EXTRA_SUBJECT, activity.getString(R.string.feedback_subject));

    try {/* www. ja  v a2s . c  om*/
        startActivity(Intent.createChooser(intent, activity.getString(R.string.send_feedback)));
    } catch (Exception e) {
        Toast.makeText(activity, activity.getString(R.string.feedback_error_msg), Toast.LENGTH_SHORT).show();
    }
}

From source file:org.jared.synodroid.ds.ui.HelpFragment.java

/**
 * Activity creation//from ww  w . j  ava2 s . co m
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    try {
        if (((Synodroid) getActivity().getApplication()).DEBUG)
            Log.v(Synodroid.DS_TAG, "HelpFragment: Creating help fragment");
    } catch (Exception ex) {
        /*DO NOTHING*/}

    final FragmentActivity helpActivity = this.getActivity();
    View help = inflater.inflate(R.layout.help, null, false);
    Button helpBtn = (Button) help.findViewById(R.id.id_email);
    helpBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            try {
                final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                emailIntent.setType("plain/text");
                emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                        new String[] { "synodroid@gmail.com" });
                emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Synodroid Free - help");
                startActivity(emailIntent);
            } catch (Exception e) {
                AlertDialog.Builder builder = new AlertDialog.Builder(helpActivity);
                builder.setMessage(R.string.err_noemail);
                builder.setTitle(getString(R.string.connect_error_title)).setCancelable(false)
                        .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.cancel();
                            }
                        });
                AlertDialog errorDialog = builder.create();
                try {
                    errorDialog.show();
                } catch (BadTokenException ex) {
                    // Unable to show dialog probably because intent has been closed. Ignoring...
                }
            }
        }
    });
    Button gplusBtn = (Button) help.findViewById(R.id.id_gplus);
    gplusBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String url = "https://plus.google.com/111893484035545745539";
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            startActivity(i);
        }
    });

    TextView main_web = (TextView) help.findViewById(R.id.syno_main_web);
    main_web.setText(Html.fromHtml("<a href=\"http://www.synology.com\">www.synology.com</a>"));
    main_web.setMovementMethod(LinkMovementMethod.getInstance());

    TextView buy = (TextView) help.findViewById(R.id.syno_buy_web);
    buy.setText(Html.fromHtml(
            "<a href=\"http://www.synology.com/support/wheretobuy.php\">www.synology.com/support/wheretobuy.php</a>"));
    buy.setMovementMethod(LinkMovementMethod.getInstance());

    return help;
}

From source file:com.workingagenda.devinettes.AboutActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        return true;
    case R.id.action_source:
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse("https://github.com/fenimore/devinettes-android"));
        startActivity(i);//from   ww  w.jav  a2  s  .co  m
        return true;
    case R.id.action_mail:
        String[] addresses = new String[1];
        addresses[0] = "exorable.ludos@gmail.com";
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("*/*");
        intent.putExtra(Intent.EXTRA_EMAIL, addresses);
        intent.putExtra(Intent.EXTRA_SUBJECT, "Riddle Answer Please :)");
        intent.putExtra(Intent.EXTRA_TEXT,
                "Please include the Riddle you're interested" + "in, and the donation amount.");
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        }
        startActivity(intent);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

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 . j  a  va 2s  . c  om
        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;/* ww w .j  a  va 2 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.vixir.finalproject.perfectday.fragment.MoreInfoFragment.java

@OnClick(R.id.feedback)
public void onClickFeedBack() {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("plain/text");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { getString(R.string.my_email) });
    intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.mail_subject));
    startActivity(Intent.createChooser(intent, ""));
}

From source file:org.stenerud.kscrash.KSCrashReportFilterEmail.java

@Override
public void filterReports(List reports, CompletionCallback completionCallback)
        throws KSCrashReportFilteringFailedException {
    ArrayList<Uri> attachments = new ArrayList<>();
    String authority = BuildConfig.APPLICATION_ID + ".provider";
    for (Object report : reports) {
        attachments.add(FileProvider.getUriForFile(context, authority, (File) report));
    }//w w  w  . ja va  2s .c o m

    Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent.setType("*/*");
    // TODO: Why does this fail?
    //        intent.setData(Uri.parse("mailto:"));
    intent.putExtra(Intent.EXTRA_EMAIL, recipients.toArray());
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    // Workaround for framework bug
    ArrayList<String> text = new ArrayList<>();
    text.add(message);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    intent.putExtra(Intent.EXTRA_STREAM, attachments);

    if (intent.resolveActivity(context.getPackageManager()) != null) {
        context.startActivity(intent);
    }

    completionCallback.onCompletion(reports);
}

From source file:com.fanfou.app.opensource.util.IntentHelper.java

public static void startEmailIntent(final Context context, final String emailAddress) {
    try {/*from w  ww.j  a va  2  s .  c  o  m*/
        final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
        intent.setType("plain/text");
        intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { emailAddress });
        context.startActivity(intent);
    } catch (final Exception ex) {
        Log.e(IntentHelper.TAG, "Error starting email intent.", ex);
        Toast.makeText(context, "Sorry, we couldn't find any app for sending emails!", Toast.LENGTH_SHORT)
                .show();
    }
}