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.codeskraps.sbrowser.home.SBrowserActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    if (item.getItemId() == R.id.itemQuit) {

        try {/* w  ww  .  jav a 2 s.c o m*/
            dataBaseData.deleteTable(DataBaseData.DB_TABLE_TABS);
        } catch (Exception e) {
            Log.e(TAG, "deleteTable: " + e.getMessage());
        }
        this.finish();
        overridePendingTransition(R.anim.fadein, R.anim.fadeout);

    } else if (item.getItemId() == R.id.itemFeedback) {

        Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

        String aEmailList[] = { "codeskraps@gmail.com" };

        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "sBrowser - Feedback");
        emailIntent.setType("plain/text");

        startActivity(Intent.createChooser(emailIntent, "Send your feedback in:"));

        /*-
        } else if (item.getItemId() == R.id.itemBuyMeAPint) {
                
           try {
              Intent marketIntent = new Intent(Intent.ACTION_VIEW);
              marketIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY
             | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
              startActivity(marketIntent.setData(Uri.parse("market://developer?id=Codeskraps")));
           } catch (Exception e) {
              Intent browserIntent = new Intent(Intent.ACTION_VIEW,
             Uri.parse("http://play.google.com/store/apps/developer?id=Codeskraps"));
              browserIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY
             | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
              startActivity(browserIntent);
              Log.e(TAG, e.getMessage());
           }
         */
    } else {

        try {
            Picture picture = webView.capturePicture();
            PictureDrawable pictureDrawable = new PictureDrawable(picture);
            Bitmap bitmap = Bitmap.createBitmap(300, 300, Config.ARGB_8888);
            Canvas canvas = new Canvas(bitmap);
            canvas.drawPicture(pictureDrawable.getPicture());
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            bitmap.compress(android.graphics.Bitmap.CompressFormat.PNG, 100, (OutputStream) bos);
            bitmap.isRecycled();

            BookmarkItem bookmarkItem = new BookmarkItem(webView.getTitle(), webView.getUrl());
            bookmarkItem.setImage(bos.toByteArray());
            sBrowserData.setBookmarkItem(bookmarkItem);
            bos.close();

        } catch (Exception e) {
            Log.e(TAG, "Picture:" + e.getMessage());
            BookmarkItem bookmarkItem = new BookmarkItem("Set title", "Set url");
            bookmarkItem.setImage(null);
            sBrowserData.setBookmarkItem(bookmarkItem);
        }

        SBrowserApplication sBrwoserApp = (SBrowserApplication) getApplication();
        SBrowserActivity.this.startActivity(sBrwoserApp.getMenuIntent(item, SBrowserActivity.this));
        overridePendingTransition(R.anim.fadein, R.anim.fadeout);
    }

    return super.onOptionsItemSelected(item);
}

From source file:org.gnucash.android.export.ExporterAsyncTask.java

/**
 * Starts an intent chooser to allow the user to select an activity to receive
 * the exported OFX file//from   w  w  w  .  j a  v a2  s  . co  m
 * @param path String path to the file on disk
 */
private void shareFile(String path) {
    String defaultEmail = PreferenceManager.getDefaultSharedPreferences(mContext)
            .getString(mContext.getString(R.string.key_default_export_email), null);
    Intent shareIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    shareIntent.setType("application/xml");
    ArrayList<Uri> exportFiles = new ArrayList<Uri>();
    if (mExportParams.getExportFormat() == ExportFormat.QIF) {
        try {
            List<String> splitFiles = splitQIF(new File(path), new File(path));
            for (String file : splitFiles) {
                exportFiles.add(Uri.parse("file://" + file));
            }
        } catch (IOException e) {
            Log.e(TAG, "error split up files in shareFile");
            e.printStackTrace();
            return;
        }
    } else {
        exportFiles.add(Uri.parse("file://" + path));
    }
    shareIntent.putExtra(Intent.EXTRA_STREAM, exportFiles);
    shareIntent.putExtra(Intent.EXTRA_SUBJECT,
            mContext.getString(R.string.title_export_email, mExportParams.getExportFormat().name()));
    if (defaultEmail != null && defaultEmail.trim().length() > 0) {
        shareIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { defaultEmail });
    }
    SimpleDateFormat formatter = (SimpleDateFormat) SimpleDateFormat.getDateTimeInstance();

    ArrayList<CharSequence> extraText = new ArrayList<CharSequence>();
    extraText.add(mContext.getString(R.string.description_export_email) + " "
            + formatter.format(new Date(System.currentTimeMillis())));
    shareIntent.putExtra(Intent.EXTRA_TEXT, extraText);

    mContext.startActivity(
            Intent.createChooser(shareIntent, mContext.getString(R.string.title_select_export_destination)));
}

From source file:at.alladin.rmbt.android.about.RMBTAboutFragment.java

private View createView(View view, LayoutInflater inflater) {
    activity = getActivity();//from w  ww  . j  a v  a 2 s  .  c  o m

    getAppInfo(activity);

    final String clientUUID = String.format("U%s", ConfigHelper.getUUID(activity.getApplicationContext()));

    final String controlServerVersion = ConfigHelper.getControlServerVersion(activity);

    final ListView listView = (ListView) view.findViewById(R.id.aboutList);

    final ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();

    HashMap<String, String> item;
    item = new HashMap<String, String>();
    item.put("title", clientName);
    item.put("text1", this.getString(R.string.about_rtr_line1));
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", this.getString(R.string.about_version_title));
    item.put("text1", clientVersion);
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_clientid_title));
    item.put("text1", clientUUID);
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_web_title));
    item.put("text1", getString(R.string.about_web_line1));
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_email_title));
    item.put("text1", getString(R.string.about_email_line1));
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_terms_title));
    item.put("text1", getString(R.string.about_terms_line1));
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_git_title));
    item.put("text1", getString(R.string.about_git_line1));
    item.put("text2", "");
    list.add(item);
    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_dev_title));
    item.put("text1", getString(R.string.about_dev_line1));
    item.put("text2", getString(R.string.about_dev_line2));
    list.add(item);

    final String openSourceSoftwareLicenseInfo = GooglePlayServicesUtil
            .getOpenSourceSoftwareLicenseInfo(getActivity());

    if (openSourceSoftwareLicenseInfo != null) {
        item = new HashMap<String, String>();
        item.put("title", getString(R.string.about_gms_legal_title));
        item.put("text1", getString(R.string.about_gms_legal_line1));
        item.put("text2", "");
        list.add(item);
    }

    if (ConfigHelper.isDevEnabled(getActivity())) {
        item = new HashMap<String, String>();
        item.put("title", getString(R.string.about_test_counter_title));
        item.put("text1", Integer.toString(ConfigHelper.getTestCounter(getActivity())));
        item.put("text2", "");
        list.add(item);
    }

    item = new HashMap<String, String>();
    item.put("title", getString(R.string.about_control_server_version));
    item.put("text1", controlServerVersion != null ? controlServerVersion : "---");
    item.put("text2", "");
    list.add(item);

    sa = new RMBTAboutAdapter(getActivity(), list, R.layout.about_item,
            new String[] { "title", "text1", "text2" }, new int[] { R.id.title, R.id.text1, R.id.text2 });

    listView.setAdapter(sa);

    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(final AdapterView<?> l, final View v, final int position, final long id) {

            switch (position) {

            case 1:
                handleHiddenCode();
                break;

            case 2:
                final android.content.ClipboardManager clipBoard = (android.content.ClipboardManager) getActivity()
                        .getSystemService(Context.CLIPBOARD_SERVICE);
                ClipData clip = ClipData.newPlainText("client_uuid", clientUUID);
                clipBoard.setPrimaryClip(clip);
                final Toast toast = Toast.makeText(getActivity(), R.string.about_clientid_toast,
                        Toast.LENGTH_LONG);
                toast.show();
                break;

            case 3:
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.about_web_link))));
                break;

            case 4:
                /* Create the Intent */
                final Intent emailIntent = new Intent(Intent.ACTION_SEND);

                /* Fill it with Data */
                emailIntent.setType("plain/text");
                emailIntent.putExtra(Intent.EXTRA_EMAIL,
                        new String[] { getString(R.string.about_email_email) });
                emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.about_email_subject));
                emailIntent.putExtra(Intent.EXTRA_TEXT, "");

                /* Send it off to the Activity-Chooser */
                startActivity(Intent.createChooser(emailIntent, getString(R.string.about_email_sending)));

                break;

            case 5:
                final FragmentManager fm = activity.getSupportFragmentManager();
                FragmentTransaction ft;
                ft = fm.beginTransaction();
                ft.replace(R.id.fragment_content, new RMBTTermsFragment(), "terms");
                ft.addToBackStack("terms");
                ft.commit();
                break;

            case 6:
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.about_git_link))));
                break;

            case 7:
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.about_dev_link))));
                break;

            case 8:
                final String licenseInfo = GooglePlayServicesUtil
                        .getOpenSourceSoftwareLicenseInfo(getActivity());
                AlertDialog.Builder licenseDialog = new AlertDialog.Builder(getActivity());
                licenseDialog.setMessage(licenseInfo);
                licenseDialog.show();
                break;

            default:
                break;
            }
        }

    });

    return view;
}

From source file:ir.rasen.charsoo.view.fragment.FragmentUserRegisterOfferFriendInvite.java

public static Intent createEmailIntent(final String[] toEmail, final String subject, final String message) {
    String emailsString = "";
    if (toEmail.length > 0)
        emailsString = toEmail[0];/*from   w  w  w . j  a  v a2s.c  o m*/

    for (int i = 1; i < toEmail.length; i++) {
        emailsString += ",";
        emailsString += toEmail[i];
    }
    Intent sendTo = new Intent(Intent.ACTION_SENDTO);
    String uriText = "mailto:" + Uri.encode(emailsString) + "?subject=" + Uri.encode(subject) + "&body="
            + Uri.encode(message);
    Uri uri = Uri.parse(uriText);
    sendTo.setData(uri);

    List<ResolveInfo> resolveInfos = context.getPackageManager().queryIntentActivities(sendTo, 0);

    // Emulators may not like this check...
    if (!resolveInfos.isEmpty()) {
        return Intent.createChooser(sendTo, "Send Email");
    }

    // Nothing resolves send to, so fallback to send...
    Intent send = new Intent(Intent.ACTION_SEND);

    send.setType("message/rfc822");
    send.putExtra(Intent.EXTRA_EMAIL, toEmail);
    send.putExtra(Intent.EXTRA_SUBJECT, subject);
    send.putExtra(Intent.EXTRA_TEXT, message);

    return Intent.createChooser(send, "Send Email");
}

From source file:com.altcanvas.twitspeak.TwitSpeakActivity.java

public boolean checkStackTrace() {
    FileInputStream traceIn = null;
    try {/*w w  w.  j a  v a  2 s .  co m*/
        traceIn = openFileInput("stack.trace");
        traceIn.close();
    } catch (FileNotFoundException fnfe) {
        // No stack trace available
        return false;
    } catch (IOException ioe) {
        return false;
    }

    AlertDialog alert = new AlertDialog.Builder(this).create();
    alert.setMessage(getResources().getString(R.string.crashreport_msg));

    alert.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.emailstr),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    String trace = "";
                    String line = null;
                    try {
                        BufferedReader reader = new BufferedReader(
                                new InputStreamReader(TwitSpeakActivity.this.openFileInput("stack.trace")));
                        while ((line = reader.readLine()) != null) {
                            trace += line + "\n";
                        }
                    } catch (FileNotFoundException fnfe) {
                        Log.logException(TAG, fnfe);
                    } catch (IOException ioe) {
                        Log.logException(TAG, ioe);
                    }

                    Intent sendIntent = new Intent(Intent.ACTION_SEND);
                    String subject = "Error report";
                    String body = getResources().getString(R.string.mailthisto_msg) + " jayesh@altcanvas.com: "
                            + "\n\n" + G.getPhoneInfo() + "\n\n" + "TwitSpeak [" + G.VERSION_STRING + "]"
                            + "\n\n" + trace + "\n\n";

                    sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "jayesh@altcanvas.com" });
                    sendIntent.putExtra(Intent.EXTRA_TEXT, body);
                    sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
                    sendIntent.setType("message/rfc822");

                    TwitSpeakActivity.this.startActivityForResult(
                            Intent.createChooser(sendIntent, getResources().getString(R.string.emailstr)),
                            G.REQCODE_EMAIL_STACK_TRACE);

                    TwitSpeakActivity.this.deleteFile("stack.trace");
                }
            });
    alert.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancelstr),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    TwitSpeakActivity.this.deleteFile("stack.trace");
                    TwitSpeakActivity.this.continueOnCreate();
                }
            });

    alert.setOnCancelListener(new DialogInterface.OnCancelListener() {
        public void onCancel(DialogInterface dialog) {
            TwitSpeakActivity.this.deleteFile("stack.trace");
            TwitSpeakActivity.this.continueOnCreate();
        }
    });

    alert.show();

    return true;
}

From source file:org.thoughtcrime.securesms.logsubmit.SubmitLogFragment.java

private Intent getIntentForSupportEmail(String logUrl) {
    Intent emailSendIntent = new Intent(Intent.ACTION_SEND);

    emailSendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { supportEmailAddress });
    emailSendIntent.putExtra(Intent.EXTRA_SUBJECT, supportEmailSubject);
    emailSendIntent.putExtra(Intent.EXTRA_TEXT,
            getString(R.string.log_submit_activity__please_review_this_log_from_my_app, logUrl));
    emailSendIntent.setType("message/rfc822");

    return emailSendIntent;
}

From source file:com.achep.base.ui.fragments.dialogs.FeedbackDialog.java

private void send(@NonNull CharSequence title, @NonNull CharSequence body, boolean attachLog) {
    Activity context = getActivity();/* www .j a  va 2  s .  c o m*/
    String[] recipients = { Build.SUPPORT_EMAIL };
    Intent intent = new Intent().putExtra(Intent.EXTRA_EMAIL, recipients).putExtra(Intent.EXTRA_SUBJECT, title)
            .putExtra(Intent.EXTRA_TEXT, body);

    if (attachLog) {
        attachLog(intent);
        intent.setAction(Intent.ACTION_SEND);
        intent.setType("message/rfc822");
    } else {
        intent.setAction(Intent.ACTION_SENDTO);
        intent.setData(Uri.parse("mailto:")); // only email apps should handle it
    }

    if (IntentUtils.hasActivityForThat(context, intent)) {
        startActivity(intent);
        dismiss();
    } else {
        ToastUtils.showLong(context, R.string.feedback_error_no_app);
    }
}

From source file:piuk.blockchain.android.ui.WalletActivity.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
    case R.id.wallet_options_address_book:
        WalletAddressesActivity.start(WalletActivity.this, true);
        return true;

    case R.id.wallet_options_preferences:
        startActivity(new Intent(this, PreferencesActivity.class));
        return true;

    case R.id.wallet_options_donate:
        final Intent intent = new Intent(this, SendCoinsActivity.class);
        intent.putExtra(SendCoinsActivity.INTENT_EXTRA_ADDRESS, Constants.DONATION_ADDRESS);
        startActivity(intent);/*from  w ww.  ja  v a2 s. c  om*/
        return true;

    case R.id.wallet_options_bug:
        Intent i = new Intent(Intent.ACTION_SEND);
        i.setType("text/plain");
        i.putExtra(Intent.EXTRA_EMAIL, new String[] { "support@pi.uk.com" });
        i.putExtra(Intent.EXTRA_SUBJECT, "Exception Report");

        String log = application.readExceptionLog();
        if (log != null)
            i.putExtra(Intent.EXTRA_TEXT, log);

        try {
            startActivity(Intent.createChooser(i, "Send mail..."));
        } catch (android.content.ActivityNotFoundException ex) {
            Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
        }

        return true;
    case R.id.wallet_options_help:
        showDialog(DIALOG_HELP);
        return true;
    }

    return false;
}

From source file:com.justplay1.shoppist.features.lists.MainActivity.java

@Override
public void onFeedbackClick() {
    menuDrawer.addDrawerListener(new DrawerListener() {
        @Override//from   www. j  a  v a2 s  . co  m
        public void onDrawerClosed(View drawerView) {
            Intent sendIntent = new Intent();
            sendIntent.setAction(Intent.ACTION_SEND);
            sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { getString(R.string.app_email) });
            sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name) + " Version: "
                    + ShoppistUtils.getAppVersion(MainActivity.this));
            sendIntent.setType("message/rfc822");
            startActivity(Intent.createChooser(sendIntent, getString(R.string.send_mail_using)));
            menuDrawer.removeDrawerListener(this);
        }
    });
    menuDrawer.closeDrawers();
}

From source file:com.denel.facepatrol.MainActivity.java

public void onGroupEmail(String[] email_grp) {
    // enter code here 
    Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
    emailIntent.setData(Uri.parse("mailto:"));
    emailIntent.putExtra(Intent.EXTRA_EMAIL, email_grp);
    //emailIntent.setType("message/rfc822");
    emailIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    startActivity(Intent.createChooser(emailIntent, "Send Group Email..."));
}