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:fr.project.mlignereux.cv.view.fragment.ContactFragment.java

private void sendMail(final String email) {

    mFab2.setOnClickListener(new View.OnClickListener() {
        @Override/*from   w w w.j  a v  a2s.  c o m*/
        public void onClick(View view) {
            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("message/rfc822");
            i.putExtra(Intent.EXTRA_EMAIL, new String[] { email });

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

}

From source file:com.uoit.freeroomfinder.SettingsActivity.java

/**
 * setupSimplePreferencesScreen Shows the simplified settings UI if the device configuration if
 * the device configuration dictates that a simplified, single-pane UI should be shown.
 *///  w w w.j a v  a2  s . c  o  m
@SuppressWarnings("deprecation")
private void setupSimplePreferencesScreen() {
    if (!isSimplePreferences(this)) {
        return;
    }

    // In the simplified UI, fragments are not used at all and we instead
    // use the older PreferenceActivity APIs.
    // Add 'general' preferences.
    addPreferencesFromResource(R.xml.pref_general);

    PreferenceDialog deleteAccount = (PreferenceDialog) this.findPreference("delete_account");

    DatabaseInterface dbi = new DatabaseInterface(getBaseContext());

    // Disable delete account if user does not have an account
    if (dbi.getUser() == null) {
        deleteAccount.setEnabled(false);
        deleteAccount.setSelectable(false);
    } else {
        deleteAccount.setEnabled(true);
        deleteAccount.setSelectable(true);
    }

    // Contains the logic for when the preferences dialog is closed.
    deleteAccount.setOnPreferenceDialogClosedListener(new OnPreferenceDialogClosedListener() {
        /*
         * (non-Javadoc)
         * 
         * @see com.uoit.freeroomfinder.preferences.OnPreferenceDialogClosedListener#
         * onPreferenceDialogClosed(boolean)
         */
        @Override
        public void onPreferenceDialogClosed(boolean positiveResult) {
            if (positiveResult) {
                DatabaseInterface dbi = new DatabaseInterface(getBaseContext());
                dbi.deleteAll();
            }
        }
    });

    // Add 'search' preferences, and a corresponding header.
    PreferenceCategory fakeHeader = new PreferenceCategory(this);
    fakeHeader.setTitle(R.string.pref_header_search);
    getPreferenceScreen().addPreference(fakeHeader);
    addPreferencesFromResource(R.xml.pref_search);

    // Contains the logic for setting the 24 hour clock preferences.
    findPreference("army_clock").setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        /*
         * (non-Javadoc)
         * 
         * @see
         * android.preference.Preference.OnPreferenceChangeListener#onPreferenceChange(android
         * .preference.Preference, java.lang.Object)
         */
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            DateTimeUtility.setArmyClock(Boolean.valueOf(newValue.toString()));
            return true;
        }

    });

    // Add 'feedback' preferences, and a corresponding header.
    fakeHeader = new PreferenceCategory(this);
    fakeHeader.setTitle(R.string.pref_header_feedback);
    getPreferenceScreen().addPreference(fakeHeader);
    addPreferencesFromResource(R.xml.pref_feedback);

    findPreference("source_code").setOnPreferenceClickListener(new OnPreferenceClickListener() {
        /*
         * (non-Javadoc)
         * 
         * @see
         * android.preference.Preference.OnPreferenceClickListener#onPreferenceClick(android
         * .preference.Preference)
         */
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(SettingsActivity.this.getString(R.string.source_code_site)));
            SettingsActivity.this.startActivity(i);
            return true;
        }
    });

    /* Set an onclick listener for contact developers */
    findPreference("contact").setOnPreferenceClickListener(new OnPreferenceClickListener() {
        /*
         * (non-Javadoc)
         * 
         * @see
         * android.preference.Preference.OnPreferenceClickListener#onPreferenceClick(android
         * .preference.Preference)
         */
        @Override
        public boolean onPreferenceClick(Preference preference) {
            /**
             * Create the Intent
             */
            final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

            /**
             * Fill it with Data
             */
            emailIntent.setType("plain/text");
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                    SettingsActivity.this.getResources().getStringArray(R.array.dev_emails));
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Free Room Finder");
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "");

            /**
             * Send it off to the Activity-Chooser
             */
            SettingsActivity.this.startActivity(Intent.createChooser(emailIntent, "Email the developers..."));
            return true;
        }
    });
}

From source file:stanlee.project.com.efikhymns.main_hymn_activity.java

@SuppressWarnings("StatementWithEmptyBody")
@Override/*  ww  w .jav a 2  s .  c  o  m*/
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_Hymn) {
        //Takes you the Main Hymn
    } else if (id == R.id.setting) {
        startActivity(new Intent(main_hymn_activity.this, Setting.class));
    } else if (id == R.id.nav_About) {
        startActivity(new Intent(main_hymn_activity.this, About.class));
    } else if (id == R.id.nav_Help) {
        Intent emailIntent = new Intent(Intent.ACTION_SEND);
        emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "success4stan@gmail.com" });
        emailIntent.putExtra(Intent.EXTRA_CC, new String[] { "cjajomiwe@gmail.com" });
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "The Hymn Book " + BuildConfig.VERSION_NAME);
        emailIntent.setType("message/rfc82");
        startActivity(Intent.createChooser(emailIntent, "Send Email Using ...."));
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

From source file:com.evo.passwordgenerator.activities.AboutActivity_test2.java

@Override
protected MaterialAboutList getMaterialAboutList(final Context c) {
    updateRecentTasksUi();/*from ww  w  .  j  ava  2  s  .com*/
    MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder();

    appCardBuilder.addItem(
            new MaterialAboutTitleItem.Builder().text(R.string.app_name).icon(R.mipmap.ic_launcher).build());

    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.version)
            .subText(versionname + " " + "(" + versioncode + ")")
            .icon(new IconicsDrawable(c).icon(GoogleMaterial.Icon.gmd_info_outline)
                    .color(ContextCompat.getColor(c, colorVersion)).sizeDp(18))
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    if (++ntvc == MAX_CLICKS) {
                        ntvc = 0;
                        Snackbar snackbar = Snackbar
                                .make(((AboutActivity_test2) c)
                                        .findViewById(R.id.mal_material_about_activity_coordinator_layout),
                                        "Congrats! You found me :D", Snackbar.LENGTH_LONG)
                                .setAction(android.R.string.ok, new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                    }
                                });

                        snackbar.setActionTextColor(getResources().getColor(R.color.colorAccent));
                        snackbar.setDuration(3000);
                        snackbar.show();
                    } else {
                    }
                }
            }).build());

    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.changelog)
            .icon(new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_history)
                    .color(ContextCompat.getColor(c, colorChangelog)).sizeDp(18))
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    showChangelog();
                }
            }).build());

    appCardBuilder
            .addItem(new MaterialAboutActionItem.Builder().text(R.string.rate_title).subText(R.string.rate)
                    .icon(new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_star)
                            .color(ContextCompat.getColor(c, colorRate)).sizeDp(20))
                    .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                        @Override
                        public void onClick() {
                            Intent intentrate = new Intent(Intent.ACTION_VIEW);
                            intentrate.setData(Uri.parse(
                                    "https://labs.xda-developers.com/store/app/com.evo.passwordgenerator"));
                            c.startActivity(intentrate);
                        }
                    }).build());

    final String[] translators = new String[5];
    translators[0] = "Vojtechh (" + getString(R.string.czech) + " " + getString(R.string.translators) + ")";
    translators[1] = "BBB";
    translators[2] = "CCC";
    translators[3] = "DDD";
    translators[4] = "EEE";

    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.translators)
            .subText(R.string.list_all_translators)
            .icon(new IconicsDrawable(c).icon(GoogleMaterial.Icon.gmd_flag)
                    .color(ContextCompat.getColor(c, colorTranslators)).sizeDp(18))
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    MaterialDialog.Builder builder = new MaterialDialog.Builder(c).title(R.string.translators)
                            .items(translators).positiveText(android.R.string.ok)
                            .onPositive(new MaterialDialog.SingleButtonCallback() {
                                @Override
                                public void onClick(@NonNull MaterialDialog dialog,
                                        @NonNull DialogAction which) {
                                    dialog.dismiss();
                                }
                            }).positiveColorRes(R.color.colorAccent).autoDismiss(false);

                    MaterialDialog dialog = builder.build();
                    dialog.show();
                }
            }).build());

    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.libraries)
            .icon(new IconicsDrawable(c).icon(GoogleMaterial.Icon.gmd_bookmark)
                    .color(ContextCompat.getColor(c, colorLibraries)).sizeDp(18))
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    displayLibrariesDialogFragment();
                }
            }).build());

    MaterialAboutCard.Builder authorCardBuilder = new MaterialAboutCard.Builder();
    authorCardBuilder.title(R.string.developer);
    authorCardBuilder.titleColor(ContextCompat.getColor(c, R.color.colorAccent));

    authorCardBuilder
            .addItem(new MaterialAboutActionItem.Builder().text("EvoWizz").subText(R.string.dev_subtext)
                    .icon(new IconicsDrawable(c).icon(GoogleMaterial.Icon.gmd_person)
                            .color(ContextCompat.getColor(c, colorIcon)).sizeDp(18))
                    .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                        @Override
                        public void onClick() {
                            displayLicenseDialogFragment();
                        }
                    }).build());

    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.emailtext)
            .icon(new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_email)
                    .color(ContextCompat.getColor(c, colorEmail)).sizeDp(18))
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    Intent intentemail = new Intent(Intent.ACTION_SEND);
                    intentemail.setType("message/rfc822");
                    intentemail.putExtra(Intent.EXTRA_EMAIL, new String[] { "EvoWizzFR@gmail.com" });
                    c.startActivity(intentemail);
                }
            }).build());

    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.followmeT)
            .icon(new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_twitter)
                    .color(ContextCompat.getColor(c, colorTwitter)).sizeDp(18))
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    Intent intenttwitter = new Intent(Intent.ACTION_VIEW);
                    intenttwitter.setData(Uri.parse("https://twitter.com/EvoWizz"));
                    c.startActivity(intenttwitter);
                }
            }).build());

    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.followmeG)
            .icon(new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_google_plus)
                    .color(ContextCompat.getColor(c, colorGooglePlus)).sizeDp(22))
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    Intent intentgoogleplus = new Intent(Intent.ACTION_VIEW);
                    intentgoogleplus.setData(Uri.parse("https://plus.google.com/+EvoWizz"));
                    c.startActivity(intentgoogleplus);
                }
            }).build());

    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.followmeI)
            .icon(new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_instagram)
                    .color(ContextCompat.getColor(c, colorInstagram)).sizeDp(18))
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    Intent intentinstagram = new Intent(Intent.ACTION_VIEW);
                    intentinstagram.setData(Uri.parse("https://www.instagram.com/EvoWizz/"));
                    c.startActivity(intentinstagram);
                }
            }).build());

    MaterialAboutCard.Builder supdevCardBuilder = new MaterialAboutCard.Builder();
    supdevCardBuilder.title(R.string.sup_dev);
    supdevCardBuilder.titleColor(ContextCompat.getColor(c, R.color.colorAccent));

    supdevCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.issue_reporter_title)
            .subText(R.string.issue_reporter)
            .icon(new IconicsDrawable(c).icon(GoogleMaterial.Icon.gmd_bug_report)
                    .color(ContextCompat.getColor(c, colorReporter)).sizeDp(18))
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    Intent reporter = new Intent(c, GHReporter.class);
                    c.startActivity(reporter);
                }
            }).build());

    supdevCardBuilder.addItem(
            new MaterialAboutActionItem.Builder().text(R.string.translate_title).subText(R.string.translate)
                    .icon(new IconicsDrawable(c).icon(GoogleMaterial.Icon.gmd_translate)
                            .color(ContextCompat.getColor(c, colorTranslate)).sizeDp(18))
                    .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                        @Override
                        public void onClick() {
                            Intent reporter = new Intent(c, GHReporter.class);
                            c.startActivity(reporter);
                        }
                    }).build());

    return new MaterialAboutList(appCardBuilder.build(), authorCardBuilder.build(), supdevCardBuilder.build());
}

From source file:org.gnucash.android.ui.accounts.ExportDialogFragment.java

/**
 * Starts an intent chooser to allow the user to select an activity to receive
 * the exported OFX file/* ww w.jav  a2s . co  m*/
 * @param path String path to the file on disk
 */
private void shareFile(String path) {
    String defaultEmail = PreferenceManager.getDefaultSharedPreferences(getActivity())
            .getString(getString(R.string.key_default_export_email), null);
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("application/xml");
    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + path));
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.title_export_email));
    if (defaultEmail != null && defaultEmail.trim().length() > 0) {
        shareIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { defaultEmail });
    }
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd HH:mm");
    shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.description_export_email)
            + formatter.format(new Date(System.currentTimeMillis())));
    startActivity(Intent.createChooser(shareIntent, getString(R.string.title_share_ofx_with)));
}

From source file:com.meetingninja.csse.user.RegisterActivity.java

private void parseSDKRegistration(final User user) {
    ParseUser parseUser = new ParseUser();
    parseUser.setUsername(user.getDisplayName());
    parseUser.setPassword(passwordText.getText().toString().trim());
    parseUser.setEmail(user.getEmail());

    // other fields can be set just like with ParseObject
    parseUser.put("backendId", user.getID());
    parseUser.put("phone", user.getPhone());
    parseUser.put("company", user.getCompany());
    parseUser.put("title", user.getTitle());
    parseUser.put("location", user.getLocation());

    parseUser.signUpInBackground(new SignUpCallback() {
        public void done(ParseException e) {
            if (e == null) {
                Intent goLogin = new Intent();
                goLogin.putExtra(Intent.EXTRA_EMAIL, user.getEmail());
                goLogin.putExtra("registerSuccess", mRegisterSuccess);
                setResult(RESULT_OK, goLogin);
                finish();/*w  ww  .  java 2s. com*/
            } else {
                e.printStackTrace();
            }
        }
    });

}

From source file:uno.weichen.abnd10_inventoryapp.DetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);

    // Find all relevant views that we will need to read user input from
    mNameEditText = (EditText) findViewById(R.id.edit_product_name);
    mPriceEditText = (EditText) findViewById(R.id.edit_product_price);
    mQuantityTextView = (TextView) findViewById(R.id.textview_product_quantity);
    mContactEditText = (EditText) findViewById(R.id.edit_product_contact);
    mSoldQuantityTextView = (TextView) findViewById(R.id.textview_product_sold_quantity);
    mRestockQuantityTextView = (TextView) findViewById(R.id.textview_product_restock_quantity);
    mSaleButton = (Button) findViewById(R.id.button_sale_product);
    mRestockButton = (Button) findViewById(R.id.button_restock_product);
    mDeleteButton = (Button) findViewById(R.id.button_delete_product);
    mOrderButton = (Button) findViewById(R.id.button_order);

    mProductPhotoImageView = (ImageView) findViewById(R.id.image);

    // Use getIntent and getData to get the associated URI
    mCurrentProductUri = getIntent().getData();
    //Set title of DetailActivity on which situation we have
    if (mCurrentProductUri == null) {
        setTitle(getString(R.string.editor_activity_title_new_product));
        invalidateOptionsMenu();/* ww w.j a  v a  2  s .  co  m*/
        mDeleteButton.setVisibility(View.GONE);
    } else {
        setTitle(getString(R.string.editor_activity_title_edit_product));
        /**
         * Initializes the CursorLoader. The URL_LOADER value is eventually passed
         * to onCreateLoader().
         */
        getSupportLoaderManager().initLoader(PRODUCTION_ITEM_LOADER, null, this);
    }

    // Setup onTouchListener for editors components.
    mNameEditText.setOnTouchListener(mTouchListener);
    mPriceEditText.setOnTouchListener(mTouchListener);
    mContactEditText.setOnTouchListener(mTouchListener);

    //Onclick Listener for Sale
    mSaleButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String soldQuantityString = mSoldQuantityTextView.getText().toString().trim();
            String quantityString = mQuantityTextView.getText().toString().trim();
            int soldQuantityInt = Integer.parseInt(soldQuantityString);
            int quantityInt = Integer.parseInt(quantityString);
            if (quantityInt > 0) {
                //if button clicked and quantity > 0
                soldQuantityInt++;
                quantityInt--;
                soldQuantityString = Integer.toString(soldQuantityInt);
                quantityString = Integer.toString(quantityInt);
                mQuantityTextView.setText(quantityString);
                mSoldQuantityTextView.setText(soldQuantityString);
                //inform the user the product detail has been changed.
                mProductHasChanged = true;
            }
        }
    });

    //Onclick Listener for Restock
    mRestockButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String restockQuantityString = mRestockQuantityTextView.getText().toString().trim();
            String quantityString = mQuantityTextView.getText().toString().trim();
            int restockQuantityInt = Integer.parseInt(restockQuantityString);
            int quantityInt = Integer.parseInt(quantityString);
            //if button clicked
            restockQuantityInt++;
            quantityInt++;
            restockQuantityString = Integer.toString(restockQuantityInt);
            quantityString = Integer.toString(quantityInt);
            mQuantityTextView.setText(quantityString);
            mRestockQuantityTextView.setText(restockQuantityString);
            //inform the user the product detail has been changed.
            mProductHasChanged = true;
        }
    });

    //Onclick Listener for Delete
    mDeleteButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showDeleteConfirmationDialog();
        }
    });

    //Onclick Listener for Order
    mOrderButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String subject = "Restocking Request";
            String body = "Dear Supplier, \n" + "We need more " + mNameEditText.getText().toString().trim()
                    + ".\n" + "Please contact us! \n";

            Intent intent = new Intent(Intent.ACTION_SENDTO);
            intent.setData(Uri.parse("mailto:")); // only email apps should handle this
            intent.putExtra(Intent.EXTRA_EMAIL, new String[] { mContactEditText.getText().toString().trim() });
            intent.putExtra(Intent.EXTRA_SUBJECT, subject);
            intent.putExtra(Intent.EXTRA_TEXT, body);
            if (intent.resolveActivity(getPackageManager()) != null) {
                startActivity(intent);
            }
        }
    });

}

From source file:com.money.manager.ex.about.AboutFragment.java

private void sendLogcat() {
    String logcat = "";
    logcat = getLogcat();/*from   w  w w  . j  ava 2s  . com*/

    //send file using email
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.setType("plain/text");
    emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { Constants.EMAIL });
    // the attachment
    //        emailIntent .putExtra(Intent.EXTRA_STREAM, outputFile.getAbsolutePath());
    emailIntent.putExtra(Intent.EXTRA_TEXT, logcat);
    // the mail subject
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");

    try {
        startActivity(Intent.createChooser(emailIntent, "Send email..."));
    } catch (Exception e) {
        Timber.e(e, "opening email with logcat");
    }
}

From source file:dev.ukanth.ufirewall.RulesActivity.java

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    final Context ctx = this;

    switch (item.getItemId()) {

    case android.R.id.home: {
        onBackPressed();//from   www  .  j a  va  2  s  . c  o m
        return true;
    }
    case MENU_FLUSH_RULES:
        flushAllRules(ctx);
        return true;
    case MENU_IPV6_RULES:
        showIPv6 = true;
        populateData(this);
        return true;
    case MENU_IPV4_RULES:
        showIPv6 = false;
        populateData(this);
        return true;
    case MENU_SEND_REPORT:
        String ver;
        try {
            ver = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).versionName;
        } catch (NameNotFoundException e) {
            ver = "???";
        }
        String body = dataText + "\n\n" + getString(R.string.enter_problem) + "\n\n";
        /*String uriText = "mailto:afwall-report@googlegroups.com?subject=" +
        Uri.encode("AFWall+ problem report - v" + ver) + "&body=" +
        Uri.encode(body);*/
        final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        //email.setData(Uri.parse(uriText));

        emailIntent.setType("plain/text");
        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                new String[] { "afwall-report@googlegroups.com" });
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "AFWall+ problem report - v" + ver);
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);
        startActivity(Intent.createChooser(emailIntent, getString(R.string.send_mail)));

        // this shouldn't be necessary, but the default Android email client overrides
        // "body=" from the URI.  See MessageCompose.initFromIntent()
        //email.putExtra(Intent.EXTRA_TEXT, body);

        //startActivity(Intent.createChooser(email, getString(R.string.send_mail)));
        return true;
    }
    return super.onMenuItemSelected(featureId, item);
}

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

/**
 * Starts an intent chooser to allow the user to select an activity to receive
 * the exported OFX file/*from   w ww .  j  a v  a 2  s  .c  o  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);
    shareIntent.setType("application/xml");
    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + path));
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, mContext.getString(R.string.title_export_email));
    if (defaultEmail != null && defaultEmail.trim().length() > 0) {
        shareIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { defaultEmail });
    }
    SimpleDateFormat formatter = (SimpleDateFormat) SimpleDateFormat.getDateTimeInstance();

    shareIntent.putExtra(Intent.EXTRA_TEXT, mContext.getString(R.string.description_export_email) + " "
            + formatter.format(new Date(System.currentTimeMillis())));
    mContext.startActivity(
            Intent.createChooser(shareIntent, mContext.getString(R.string.title_share_ofx_with)));
}