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.artemchep.horario.ui.dialogs.FeedbackDialog.java

private boolean send(@NonNull CharSequence title, @NonNull CharSequence body) {
    Activity activity = getActivity();//w ww.  jav  a2 s  . c om
    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:com.hijacker.FeedbackDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    dialogView = getActivity().getLayoutInflater().inflate(R.layout.feedback_dialog, null);

    emailView = (EditText) dialogView.findViewById(R.id.email_et);
    include_report = (CheckBox) dialogView.findViewById(R.id.include_report);
    feedbackView = (EditText) dialogView.findViewById(R.id.feedback_et);
    progress = (ProgressBar) dialogView.findViewById(R.id.progress);

    emailView.setText(pref.getString("user_email", ""));
    emailView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override//from w w  w . j  a v  a2s. c o  m
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_NEXT) {
                feedbackView.requestFocus();
                return true;
            }
            return false;
        }
    });

    report = null;
    include_report.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked && report == null) {
                progress.setIndeterminate(true);
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        report = new File(Environment.getExternalStorageDirectory() + "/report.txt");
                        if (!createReport(report, path, null, Shell.getFreeShell().getShell())) {
                            if (debug)
                                Log.e("HIJACKER/feedbackDialog", "Report not generated");
                            report = null;
                        }
                        runInHandler(new Runnable() {
                            @Override
                            public void run() {
                                progress.setIndeterminate(false);
                            }
                        });
                    }
                }).start();
            }
        }
    });

    builder.setView(dialogView);
    builder.setTitle(getString(R.string.feedback));
    builder.setPositiveButton(R.string.send, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    builder.setNeutralButton(R.string.send_email, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("plain/text");
            intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "kiriakopoulos44@gmail.com" });
            intent.putExtra(Intent.EXTRA_SUBJECT, "Hijacker feedback");
            if (report != null) {
                Uri attachment = FileProvider.getUriForFile(
                        FeedbackDialog.this.getActivity().getApplicationContext(),
                        BuildConfig.APPLICATION_ID + ".provider", report);
                intent.putExtra(Intent.EXTRA_STREAM, attachment);
            }
            intent.putExtra(Intent.EXTRA_TEXT, feedbackView.getText().toString());
            startActivity(intent);
        }
    });
    return builder.create();
}

From source file:palamarchuk.smartlife.app.fragments.ProfileFragment.java

private void feedback() {
    Intent sendIntent;/*from w  w  w.  j  a v a2  s  . c o m*/
    sendIntent = new Intent(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "support@smartlife.com.kz" });
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, "");
    sendIntent.putExtra(Intent.EXTRA_TEXT, "");
    sendIntent.setType("image/jpeg");

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

From source file:de.appplant.cordova.emailcomposer.EmailComposerImpl.java

/**
 * Setter for the recipients./*from w  w  w .j ava  2s.c  o m*/
 *
 * @param recipients
 * List of email addresses.
 * @param draft
 * The intent to send.
 * @throws JSONException
 */
private void setRecipients(JSONArray recipients, Intent draft) throws JSONException {
    String[] receivers = new String[recipients.length()];

    for (int i = 0; i < recipients.length(); i++) {
        receivers[i] = recipients.getString(i);
    }

    draft.putExtra(Intent.EXTRA_EMAIL, receivers);
}

From source file:li.barter.utils.Utils.java

private static void sendEmail(final Context context, final File attachment) {

    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        final Uri path = Uri.fromFile(attachment);
        final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
        intent.setType("application/octet-stream");
        intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "barter.li database");
        final String to[] = { "vinaysshenoy@gmail.com" };
        intent.putExtra(Intent.EXTRA_EMAIL, to);
        intent.putExtra(Intent.EXTRA_TEXT, "Database");
        intent.putExtra(Intent.EXTRA_STREAM, path);
        context.startActivity(Intent.createChooser(intent, "Send mail..."));
    } else {//from   ww  w . jav  a 2 s. com
        Logger.e(TAG, "Not mounted");
    }

}

From source file:com.tomi.ginatask.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(com.tomi.ginatask.R.layout.activity_main);

    // 0. The initial step: register your license. This must be done before using MapView!
    // You can get your free/commercial license from: http://developer.nutiteq.com
    // The license string used here is intended only for Nutiteq demos and WILL NOT WORK with other apps!
    MapView.registerLicense(LICENSE_KEY, getApplicationContext());

    // 1. Basic map setup
    // Create map view 
    mapView = (EditableMapView) this.findViewById(com.tomi.ginatask.R.id.map_view);

    // Set the base projection, that will be used for most MapView, MapEventListener and Options methods
    proj = new EPSG3857();
    mapView.getOptions().setBaseProjection(proj); // note: EPSG3857 is the default, so this is actually not required

    // General options
    mapView.getOptions().setRotatable(true); // make map rotatable (this is also the default)
    mapView.getOptions().setTileThreadPoolSize(2); // use 2 download threads for tile downloading

    mapView.getOptions().setTileDrawSize(128);
    // Set initial location and other parameters, don't animate
    mapView.setFocusPos(proj.fromWgs84(new MapPos(16.9, 49.2)), 0); // Berlin
    mapView.setZoom(13, 0); // zoom 2, duration 0 seconds (no animation)
    mapView.setMapRotation(0, 0);//from w ww  .  j  av a2s.com
    mapView.setTilt(90, 0);

    // following goes normally to onCreate() of your Activity with map
    Layers retainObject = (Layers) getLastNonConfigurationInstance();
    if (retainObject != null) {
        // just restore configuration, skip other initializations
        for (int i = 0; i < retainObject.count(); i++) {
            mapView.getLayers().add(retainObject.get(i));
            retainObject.get(i).refresh();

        }
    } else {
        // Create base layer. Use vector style from assets (osmbright.zip)
        TileDataSource source = new HTTPTileDataSource(0, 20,
                "http://a.tile.openstreetmap.org/{zoom}/{x}/{y}.png");
        RasterTileLayer baseLayer = new RasterTileLayer(source);
        mapView.getLayers().add(baseLayer);
    }

    cameraButton = (Button) findViewById(com.tomi.ginatask.R.id.cameraButton);
    qrButton = (Button) findViewById(com.tomi.ginatask.R.id.qrButton);
    deviceInfoButton = (Button) findViewById(com.tomi.ginatask.R.id.deviceInfoButton);
    drawButton = (ToggleButton) findViewById(com.tomi.ginatask.R.id.drawButton);

    cameraButton.setOnClickListener(cameraButtonListener);
    qrButton.setOnClickListener(qrButtonListener);
    deviceInfoButton.setOnClickListener(deviceInfoButtonListener);

    mRegistrationBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);

            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("message/rfc822");
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            i.putExtra(Intent.EXTRA_EMAIL, new String[] { "tomisky008@gmail.com" });
            i.putExtra(Intent.EXTRA_SUBJECT, "new token");
            i.putExtra(Intent.EXTRA_TEXT, sharedPreferences.getString(QuickstartPreferences.TOKEN, ""));
            try {
                startActivity(Intent.createChooser(i, "Send mail..."));
            } catch (android.content.ActivityNotFoundException ignored) {
            }
        }
    };

    if (checkPlayServices()) {
        // Start IntentService to register this application with GCM.
        Intent intent = new Intent(this, RegistrationIntentService.class);
        startService(intent);
    }
}

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 ww  .  j a  va2s  .c  o  m
}

From source file:com.tinfoil.sms.settings.QuickPrefsActivity.java

/**
 * Things done when the preference menu is created  
 * Left as default// w ww . ja v a  2s . c om
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setupActionBar();
    /*
     * Add preferences from the options.xml file.
     */
    addPreferencesFromResource(R.xml.options);

    setKitKatPref();

    PreferenceScreen sourceCode = (PreferenceScreen) findPreference(SOURCE_CODE_SETTING_KEY);
    sourceCode.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(QuickPrefsActivity.this.getString(R.string.tinfoil_sms_github)));
            QuickPrefsActivity.this.startActivity(i);

            return true;
        }

    });

    EditTextPreference vibrateLength = (EditTextPreference) findPreference(VIBRATE_LENGTH_SETTING_KEY);
    vibrateLength.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            boolean ret = false;

            try {
                if (SMSUtility.isASmallNumber(newValue.toString())
                        && Integer.valueOf(newValue.toString()) > 0) {
                    ret = true;
                }
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
            return ret;
        }

    });

    //TODO implement the OnPreferenceChangeListener for the other preferences that use numbers only
    EditTextPreference messageLimit = (EditTextPreference) findPreference(MESSAGE_LIMIT_SETTING_KEY);
    messageLimit.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            boolean ret = false;

            try {
                if (SMSUtility.isASmallNumber(newValue.toString())
                        && Integer.valueOf(newValue.toString()) > 0) {
                    ret = true;
                }
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
            return ret;
        }
    });

    findPreference("enable_walkthrough").setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            // If walkthrough enabled, reset all the steps so they are displayed again
            if (Boolean.valueOf(newValue.toString())) {
                Walkthrough.enableWalkthrough(QuickPrefsActivity.this);
            } else {
                Walkthrough.disableWalkthrough(QuickPrefsActivity.this);
            }
            return true;
        }
    });

    /* Set an onclick listener for contact developers */
    findPreference("contact").setOnPreferenceClickListener(new OnPreferenceClickListener() {
        @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,
                    QuickPrefsActivity.this.getResources().getStringArray(R.array.dev_emails));
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                    getResources().getString(R.string.email_subject));
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "");

            /**
             * Send it off to the Activity-Chooser
             */
            QuickPrefsActivity.this.startActivity(Intent.createChooser(emailIntent,
                    QuickPrefsActivity.this.getResources().getString(R.string.email_chooser)));
            return true;
        }
    });
}

From source file:com.ieeecsvit.riviera17android.activity.MainActivity.java

@SuppressWarnings("StatementWithEmptyBody")
@Override//from   w ww.  jav a 2 s.  c o  m
public boolean onNavigationItemSelected(MenuItem item) {
    int id = item.getItemId();
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (id == R.id.wishlist) {
        Intent intent = new Intent(this, WishlistActivity.class);
        startActivity(intent);

    } else if (id == R.id.messageb) {
        Intent intent = new Intent(this, MessageActivity.class);
        startActivity(intent);

    } else if (id == R.id.feedback) {
        drawer.closeDrawer(GravityCompat.START);
        Intent i = new Intent(Intent.ACTION_SEND);
        i.setType("*/*");
        i.putExtra(Intent.EXTRA_EMAIL, new String[] { "tushar.narula17@live.com", "karishnu@gmail.com" });
        i.putExtra(Intent.EXTRA_SUBJECT, "Riviera 2017 Android App Feedback");
        startActivity(createEmailOnlyChooserIntent(i, "Send Feedback via email"));

    } else if (id == R.id.licences) {
        Intent intent = new Intent(this, LicenseActivity.class);
        startActivity(intent);

    } else if (id == R.id.contact) {
        Intent intent = new Intent(this, ContactActivity.class);
        startActivity(intent);

    } else if (id == R.id.about) {
        Intent intent = new Intent(this, AboutPage.class);
        startActivity(intent);

    } else if (id == R.id.login) {
        Intent intent = new Intent(this, LoginActivity.class);
        startActivity(intent);
        finish();
    }

    drawer.closeDrawer(GravityCompat.START);
    return true;
}

From source file:org.wahtod.wififixer.utility.LogUtil.java

public static void sendIssueReport(Activity activity, String report, File file) {
    Intent sendIntent = new Intent(Intent.ACTION_SEND);
    sendIntent.setType(activity.getString(R.string.log_mimetype));
    sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { activity.getString(R.string.email) });
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, activity.getString(R.string.subject));
    Uri uri = FileProvider.getUriForFile(activity, "org.wahtod.wififixer.files", file);
    sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
    List<ResolveInfo> resInfoList = activity.getPackageManager().queryIntentActivities(sendIntent,
            PackageManager.MATCH_DEFAULT_ONLY);
    for (ResolveInfo resolveInfo : resInfoList) {
        String packageName = resolveInfo.activityInfo.packageName;
        activity.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
    }//w w w.j  a  v a2  s  .com
    sendIntent.putExtra(Intent.EXTRA_TEXT, LogUtil.getBuildInfo() + "\n\n" + report);
    activity.startActivityForResult(Intent.createChooser(sendIntent, activity.getString(R.string.emailintent)),
            1);
}