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.desno365.mods.Activities.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.

    switch (item.getItemId()) {

    case android.R.id.home:
        if (mNavigationDrawerFragment.isDrawerOpen())
            MainNavigationDrawerFragment.mDrawerLayout.closeDrawer(findViewById(R.id.navigation_drawer));
        else/*from   w  w w  .  jav a2s.  c om*/
            MainNavigationDrawerFragment.mDrawerLayout.openDrawer(findViewById(R.id.navigation_drawer));
        return true;

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

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

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

    case R.id.action_share:
        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, getString(R.string.share_body));
        startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.share_using)));
        DesnoUtils.sendAction(mTracker, "Share");
        return true;

    case R.id.action_feedback:
        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[] { "desno365@gmail.com" });
        intent.putExtra(Intent.EXTRA_SUBJECT, "Desno365's Mods feedback");
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        }
        DesnoUtils.sendAction(mTracker, "Feedback");
        return true;

    case R.id.action_rate:
        final String appPackageName = getPackageName();
        try {
            //play store installed
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
        } catch (android.content.ActivityNotFoundException anfe) {
            //play store not installed
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
        }
        DesnoUtils.sendAction(mTracker, "Rate-app");
        return true;

    case R.id.action_settings:
        Intent intentSettings = new Intent(this, SettingsActivity.class);
        startActivity(intentSettings);
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

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

public void ContactEdit(View view) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Contact Information Feedback")
            .setMessage("You're about to edit and send personal information. "
                    + "Please note that the current database will only reflect your modification"
                    + " once the IT department verifies the change and the updated database"
                    + " is synced to your device. \n \n Do you want to continue?")
            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
                    emailIntent.setData(Uri.parse("mailto:"));
                    emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "pkantue@gmail.com" }); // this email address will change
                    emailIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                    emailIntent.putExtra(Intent.EXTRA_SUBJECT, feedback_subject);
                    emailIntent.putExtra(Intent.EXTRA_TEXT, feedback_body);
                    startActivity(Intent.createChooser(emailIntent, "Send Email..."));
                }//from www  . j a v  a 2s  .  com
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // User cancelled the dialog 
                }
            });
    builder.show();
    // exit the application
    //finish();      
}

From source file:hu.zelena.guide.MainActivity.java

public void sendFeedback(View view) {
    String version = BuildConfig.VERSION_NAME;

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("plain/text");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "zelena.patrik@simplesoft.hu" });
    intent.putExtra(Intent.EXTRA_SUBJECT, "Mobiltuds Guide - Visszajelz");
    intent.putExtra(Intent.EXTRA_TEXT, "Verzi: " + version);
    startActivity(Intent.createChooser(intent, ""));

}

From source file:com.swisscom.safeconnect.activity.DashboardActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_show_log:
        Intent logIntent = new Intent(this, LogActivity.class);
        startActivity(logIntent);//from  www.j ava 2s.  c o m
        return true;
    case R.id.menu_send_log:
        File log = Logger.saveLogs(this);
        File charonlog = new File(getFilesDir(), CharonVpnService.LOG_FILE);

        Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
        intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "manuel.cianci1@swisscom.com" });
        intent.putExtra(Intent.EXTRA_SUBJECT, "PipeOfTrust LogFiles");
        intent.setType("text/plain");

        ArrayList<Uri> files = new ArrayList<Uri>();
        if (charonlog.exists() && charonlog.length() > 0) {
            files.add(LogContentProvider.createContentUri());
        }
        if (log.exists() && log.length() > 0) {
            files.add(Uri.fromFile(log));
        }
        if (files.size() == 0) {
            Toast.makeText(this, "Log is empty!", Toast.LENGTH_SHORT).show();
            return true;
        }

        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
        startActivity(Intent.createChooser(intent, getString(R.string.send_log)));
        return true;
    case R.id.menu_change_num:
        if (mService.getState() == VpnStateService.State.CONNECTED) {
            mService.disconnect();
        }
        intent = new Intent(this, RegistrationActivity.class);
        intent.putExtra(RegistrationActivity.FORCE_ACTIVITY, true);
        startActivity(intent);
        finish();
        return true;
    case R.id.menu_help:
        startActivity(new Intent(this, FaqActivity.class));
        return true;
    case R.id.menu_settings:
        Intent settingsIntent = new Intent(this, SettingsActivity.class);
        startActivity(settingsIntent);
        return true;
    case R.id.menu_share:
        share();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.hector.invoice.views.TabExportInvoiceOrder.java

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    if (v == btBack) {
        // return to main menu view
        this.onBackPressed();
    } else if (v == btEmail) {
        String filelocation = "";
        if (currentScreenIndex == Constants.TAB_EXPORT_RECHNUNG) {
            filelocation = ExternalStorage.getFilePDFPath(InvoiceInfo.getInstance().getAppContext())
                    .getAbsolutePath() + "/" + this.fileNamePDF_R;
        } else if (currentScreenIndex == Constants.TAB_EXPORT_LIEFERSCHEIN) {
            filelocation = ExternalStorage.getFilePDFPath(InvoiceInfo.getInstance().getAppContext())
                    .getAbsolutePath() + "/" + this.fileNamePDF_L;
        } else if (currentScreenIndex == Constants.TAB_EXPORT_ANGEBOT) {
            filelocation = ExternalStorage.getFilePDFPath(InvoiceInfo.getInstance().getAppContext())
                    .getAbsolutePath() + "/" + this.fileNamePDF_A;
        }//  w  w  w .  j  av a  2 s.c o  m

        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setType("application/pdf");
        String to[] = new String[] { "@email.com" };
        sharingIntent.putExtra(Intent.EXTRA_EMAIL, to);
        Uri uri = Uri.parse("file://" + filelocation);
        sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
        sharingIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");
        startActivity(Intent.createChooser(sharingIntent, "Send email"));
    }
}

From source file:com.google.zxing.client.android.result.ResultHandler.java

final void sendEmailFromUri(String uri, String email, String subject, String body) {
    Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse(uri));
    if (email != null) {
        intent.putExtra(Intent.EXTRA_EMAIL, new String[] { email });
    }/*  w  w  w. ja va  2s . c  o m*/
    putExtra(intent, Intent.EXTRA_SUBJECT, subject);
    putExtra(intent, Intent.EXTRA_TEXT, body);
    intent.setType("text/plain");
    launchIntent(intent);
}

From source file:de.earthlingz.oerszebra.DroidZebra.java

private void sendMail() {
    //GetNowTime//from  ww w.  j a v  a2  s.c om
    Calendar calendar = Calendar.getInstance();
    Date nowTime = calendar.getTime();
    StringBuilder sbBlackPlayer = new StringBuilder();
    StringBuilder sbWhitePlayer = new StringBuilder();
    ZebraBoard gs = mZebraThread.getGameState();
    SharedPreferences settings = getSharedPreferences(SHARED_PREFS_NAME, 0);
    byte[] moves = null;
    if (gs != null) {
        moves = gs.getMoveSequence();
    }

    Intent intent = new Intent();
    Intent chooser = Intent.createChooser(intent, "");

    intent.setAction(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    intent.putExtra(Intent.EXTRA_EMAIL,
            new String[] { settings.getString(SETTINGS_KEY_SENDMAIL, DEFAULT_SETTING_SENDMAIL) });

    intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.app_name));

    //get BlackPlayer and WhitePlayer
    switch (settingsProvider.getSettingFunction()) {
    case FUNCTION_HUMAN_VS_HUMAN:
        sbBlackPlayer.append("Player");
        sbWhitePlayer.append("Player");
        break;
    case FUNCTION_ZEBRA_BLACK:
        sbBlackPlayer.append("DroidZebra-");
        sbBlackPlayer.append(settingsProvider.getSettingZebraDepth());
        sbBlackPlayer.append("/");
        sbBlackPlayer.append(settingsProvider.getSettingZebraDepthExact());
        sbBlackPlayer.append("/");
        sbBlackPlayer.append(settingsProvider.getSettingZebraDepthWLD());

        sbWhitePlayer.append("Player");
        break;
    case FUNCTION_ZEBRA_WHITE:
        sbBlackPlayer.append("Player");

        sbWhitePlayer.append("DroidZebra-");
        sbWhitePlayer.append(settingsProvider.getSettingZebraDepth());
        sbWhitePlayer.append("/");
        sbWhitePlayer.append(settingsProvider.getSettingZebraDepthExact());
        sbWhitePlayer.append("/");
        sbWhitePlayer.append(settingsProvider.getSettingZebraDepthWLD());
        break;
    case FUNCTION_ZEBRA_VS_ZEBRA:
        sbBlackPlayer.append("DroidZebra-");
        sbBlackPlayer.append(settingsProvider.getSettingZebraDepth());
        sbBlackPlayer.append("/");
        sbBlackPlayer.append(settingsProvider.getSettingZebraDepthExact());
        sbBlackPlayer.append("/");
        sbBlackPlayer.append(settingsProvider.getSettingZebraDepthWLD());

        sbWhitePlayer.append("DroidZebra-");
        sbWhitePlayer.append(settingsProvider.getSettingZebraDepth());
        sbWhitePlayer.append("/");
        sbWhitePlayer.append(settingsProvider.getSettingZebraDepthExact());
        sbWhitePlayer.append("/");
        sbWhitePlayer.append(settingsProvider.getSettingZebraDepthWLD());
    default:
    }
    StringBuilder sb = new StringBuilder();
    sb.append(getResources().getString(R.string.mail_generated));
    sb.append("\r\n");
    sb.append(getResources().getString(R.string.mail_date));
    sb.append(" ");
    sb.append(nowTime);
    sb.append("\r\n\r\n");
    sb.append(getResources().getString(R.string.mail_move));
    sb.append(" ");
    StringBuilder sbMoves = new StringBuilder();
    if (moves != null) {

        for (byte move1 : moves) {
            if (move1 != 0x00) {
                Move move = new Move(move1);
                sbMoves.append(move.getText());
                if (Objects.equal(getState().getLastMove(), move)) {
                    break;
                }
            }
        }
    }
    sb.append(sbMoves);
    sb.append("\r\n\r\n");
    sb.append(sbBlackPlayer.toString());
    sb.append("  (B)  ");
    sb.append(getState().getBlackScore());
    sb.append(":");
    sb.append(getState().getWhiteScore());
    sb.append("  (W)  ");
    sb.append(sbWhitePlayer.toString());

    intent.putExtra(Intent.EXTRA_TEXT, sb.toString());
    // Intent
    // Verify the original intent will resolve to at least one activity
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(chooser);
    }
}

From source file:com.agustinprats.myhrv.MainActivity.java

protected void sendFileByEmail(File file) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "eladfein@gmail.com" });
    intent.putExtra(Intent.EXTRA_SUBJECT, "Testing result of HRV bluetooth monitor");
    intent.putExtra(Intent.EXTRA_TEXT, "see files attached");
    Uri uri = Uri.fromFile(file);//from  w  w w.  j  a  v a  2 s.  c o  m

    intent.putExtra(Intent.EXTRA_STREAM, uri);

    startActivity(Intent.createChooser(intent, "Send email..."));

}

From source file:com.nbplus.hybrid.BasicWebViewClient.java

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    // for excel download
    if (isDocumentMimeType(url)) {
        Log.d(TAG, "This url is document mimetype = " + url);
        if (StorageUtils.isExternalStorageWritable()) {
            Uri source = Uri.parse(url);

            // Make a new request pointing to the mp3 url
            DownloadManager.Request request = new DownloadManager.Request(source);
            // Use the same file name for the destination
            File destinationFile = new File(
                    Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
                    source.getLastPathSegment());
            request.setDestinationUri(Uri.fromFile(destinationFile));
            // Add it to the manager
            mDownloadManager.enqueue(request);
            Toast.makeText(mContext, R.string.downloads_requested, Toast.LENGTH_SHORT).show();
        } else {/* w w  w  . ja va2  s . c  o m*/
            AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
            builder.setPositiveButton("?", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    //closeWebApplication();
                }
            });
            builder.setMessage(R.string.downloads_path_check);
            builder.show();
        }
        return true;
    }

    if (url.startsWith("tel:")) {
        // phone call
        if (!PhoneState.hasPhoneCallAbility(mContext)) {
            Log.d(TAG, ">> This device has not phone call ability !!!");
            return true;
        }

        mContext.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(url)));
    } else if (url.startsWith("mailto:")) {
        url = url.replaceFirst("mailto:", "");
        url = url.trim();

        Intent i = new Intent(Intent.ACTION_SEND);
        i.setType("plain/text").putExtra(Intent.EXTRA_EMAIL, new String[] { url });

        mContext.startActivity(i);
    } else if (url.startsWith("geo:")) {
        Intent searchAddress = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        mContext.startActivity(searchAddress);
    } else {
        //  URL ??   ? ??? .
        dismissProgressDialog();
        loadWebUrl(url);
        showProgressDialog();
    }
    return true;
}