Example usage for android.content Intent EXTRA_BCC

List of usage examples for android.content Intent EXTRA_BCC

Introduction

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

Prototype

String EXTRA_BCC

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

Click Source Link

Document

A String[] holding e-mail addresses that should be blind carbon copied.

Usage

From source file:mobisocial.musubi.ui.EmailUnclaimedMembersActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mHandler = new Handler();
    mIntent = getIntent();//  ww  w  . j ava2 s. c om
    mFeedUri = mIntent.getParcelableExtra(INTENT_EXTRA_FEED_URI);

    final int[] authorities = mIntent.getIntArrayExtra(INTENT_EXTRA_AUTHORITIES);
    final String recipients[] = mIntent.getStringArrayExtra(android.content.Intent.EXTRA_BCC);

    //    for debug 
    //      final String recipients[]={"574632066","640321536"};
    //      authorities[0] = Authority.Facebook.ordinal();

    Fragment memberView = new EmailUnclaimedMembersFragment();

    Bundle args = new Bundle();
    args.putParcelable("feed_uri", mFeedUri);

    memberView.setArguments(args);

    setContentView(R.layout.activity_email_unclaimed_member_list);

    Button sendButton = (Button) findViewById(R.id.send_unclaimed_email);
    Button cancelButton = (Button) findViewById(R.id.cancel_unclaimed_email);

    sendButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //TODO: need to support different invitations for different providers
            if (authorities[0] == Authority.Email.ordinal()) {
                final String subject = "You have a new Musubi message!";
                final String body = message + " " + MUSUBI_MARKET_URL;
                Intent send = new Intent(Intent.ACTION_SENDTO);
                StringBuilder recipientsString = new StringBuilder();
                // only add emails
                for (int i = 0; i < recipients.length; i++) {
                    if (authorities[i] == Authority.Email.ordinal()) {
                        recipientsString.append(recipients[i]).append(",");
                    }
                }
                recipientsString.deleteCharAt(recipientsString.length() - 1);
                String uriText;
                uriText = "mailto:" + recipientsString.toString() + "?subject=" + subject + "&body=" + body;
                //TODO: real url encoding?
                uriText = uriText.replace(" ", "%20");
                Uri uri = Uri.parse(uriText);
                send.setData(uri);
                startActivity(Intent.createChooser(send, "Send invitation..."));

                MIdentity[] identities = markAsHasSent(mIntent);
                //let other people in the feed know that spamming is unnecessary
                if (mFeedUri != null) {
                    Obj invitedObj = OutOfBandInvitedObj.from(Arrays.asList(identities).iterator());
                    Helpers.sendToFeed(EmailUnclaimedMembersActivity.this, invitedObj, mFeedUri);
                }

                EmailUnclaimedMembersActivity.this.finish();
            } else if (authorities[0] == Authority.Facebook.ordinal()) {
                Facebook fb = AccountLinkDialog.getFacebookInstance(EmailUnclaimedMembersActivity.this);
                //               AsyncFacebookRunner asyncRunner = new AsyncFacebookRunner(fb);
                //
                if (fb.isSessionValid()) {
                    //                   // TODO: batch request in json array. currently facebook limits 50 requests per batch
                    //                   // need to split up it if it's more than 50
                    //                   final String fbmsg = new StringBuilder()
                    //                      .append("message=").append(message)
                    //                      .append("&link=").append(link)
                    //                      .append("&picture=").append(LOGO_PICTURE_URL).toString();
                    //                   
                    //                   JSONArray batchObj = new JSONArray();
                    //                   try {
                    //                      for(String id : recipients) {
                    //                          JSONObject post = new JSONObject();
                    //                          post.put("method", "POST");
                    //                          post.put("relative_url", id+"/feed");
                    //                          post.put("body", fbmsg);
                    //                          batchObj.put(post);
                    //                       }
                    //                   } catch (JSONException e) {
                    //                      Log.e(TAG, e.toString());
                    //                   }
                    //                   Bundle batch = new Bundle();
                    //                   batch.putString("batch", batchObj.toString());
                    //                   asyncRunner.request("/", batch, "POST", new FriendRequestListener(), null);

                    StringBuilder recipientsString = new StringBuilder();
                    // only add fb ids
                    for (int i = 0; i < recipients.length; i++) {
                        if (authorities[i] == Authority.Facebook.ordinal()) {
                            recipientsString.append(recipients[i]).append(",");
                        }
                    }
                    recipientsString.deleteCharAt(recipientsString.length() - 1);
                    Bundle params = new Bundle();
                    params.putString("message", message);
                    params.putString("to", recipientsString.toString());
                    fb.dialog(EmailUnclaimedMembersActivity.this, "apprequests", params,
                            new AppRequestDialogListener());

                }
            }
        }
    });

    cancelButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //if i say no, i mean NO!
            markAsHasSent(mIntent);
            EmailUnclaimedMembersActivity.this.finish();
        }
    });

    getSupportFragmentManager().beginTransaction().replace(R.id.member_list, memberView).commit();

}

From source file:at.wada811.utils.IntentUtils.java

/**
 * ??Intent??// ww  w  . java  2s  . com
 *
 * @param mailto
 * @param cc
 * @param bcc
 * @param subject
 * @param body
 */
public static Intent createSendMailIntent(String[] mailto, String[] cc, String[] bcc, String subject,
        String body) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType(HTTP.PLAIN_TEXT_TYPE);
    intent.putExtra(Intent.EXTRA_EMAIL, mailto);
    intent.putExtra(Intent.EXTRA_CC, cc);
    intent.putExtra(Intent.EXTRA_BCC, bcc);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, body);
    return intent;
}

From source file:de.grobox.blitzmail.SendActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // before doing anything show notification about sending process
    mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mBuilder = new NotificationCompat.Builder(this);
    mBuilder.setContentTitle(getString(R.string.sending_mail)).setContentText(getString(R.string.please_wait))
            .setSmallIcon(R.drawable.notification_icon).setOngoing(true);
    // Sets an activity indicator for an operation of indeterminate length
    mBuilder.setProgress(0, 0, true);// www  .j  a v a 2s  .co m
    // Create Pending Intent
    notifyIntent = new Intent(this, NotificationHandlerActivity.class);
    notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notifyIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(pendingIntent);
    // Issues the notification
    mNotifyManager.notify(0, mBuilder.build());

    Properties prefs;
    try {
        prefs = getPrefs();
    } catch (Exception e) {
        String msg = e.getMessage();

        Log.i("SendActivity", "ERROR: " + msg, e);

        if (e.getClass().getCanonicalName().equals("java.lang.RuntimeException") && e.getCause() != null
                && e.getCause().getClass().getCanonicalName().equals("javax.crypto.BadPaddingException")) {
            msg = getString(R.string.error_decrypt);
        }

        showError(msg);
        return;
    }

    // get and handle Intent
    Intent intent = getIntent();
    String action = intent.getAction();

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    if (action.equals(Intent.ACTION_SEND)) {
        String text = intent.getStringExtra(Intent.EXTRA_TEXT);
        //String email   = intent.getStringExtra(Intent.EXTRA_EMAIL);
        String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
        String cc = intent.getStringExtra(Intent.EXTRA_CC);
        String bcc = intent.getStringExtra(Intent.EXTRA_BCC);

        // Check for empty content
        if (subject == null && text != null) {
            // cut all characters from subject after the 128th
            subject = text.substring(0, (text.length() < 128) ? text.length() : 128);
            // remove line breaks from subject
            subject = subject.replace("\n", " ").replace("\r", " ");
        } else if (subject != null && text == null) {
            text = subject;
        } else if (subject == null && text == null) {
            Log.e("Instant Mail", "Did not send mail, because subject and body empty.");
            showError(getString(R.string.error_no_body_no_subject));
            return;
        }

        // create JSON object with mail information
        mMail = new JSONObject();
        try {
            mMail.put("id", String.valueOf(new Date().getTime()));
            mMail.put("body", text);
            mMail.put("subject", subject);
            mMail.put("cc", cc);
            mMail.put("bcc", bcc);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        // remember mail for later
        MailStorage.saveMail(this, mMail);

        // pass mail on to notification dialog class
        notifyIntent.putExtra("mail", mMail.toString());

        // Start Mail Task
        AsyncMailTask mail = new AsyncMailTask(this, prefs, mMail);
        mail.execute();
    } else if (action.equals("BlitzMailReSend")) {
        try {
            mMail = new JSONObject(intent.getStringExtra("mail"));
        } catch (JSONException e) {
            e.printStackTrace();
        }

        // pass mail on to notification dialog class
        notifyIntent.putExtra("mail", mMail.toString());

        // Start Mail Task
        AsyncMailTask mail = new AsyncMailTask(this, prefs, mMail);
        mail.execute();
    }
    finish();
}

From source file:com.wit.android.support.content.intent.EmailIntent.java

/**
 *///w w w .  j a va2s . c  o m
@Nullable
@Override
public Intent buildIntent() {
    if (mEmails == null || mEmails.size() == 0) {
        Log.e(TAG, "Can not create an EMAIL intent. No e-mail address/-es specified.");
        return null;
    }
    /**
     * Build the intent.
     */
    final Intent intent = new Intent(Intent.ACTION_SENDTO, createEmailUri(mEmails));
    intent.putExtra(Intent.EXTRA_SUBJECT, mSubject);
    intent.putExtra(Intent.EXTRA_TEXT, mMessage);
    if (mCcEmails != null) {
        intent.putExtra(Intent.EXTRA_CC, mCcEmails.toArray());
    }
    if (mccEmails != null) {
        intent.putExtra(Intent.EXTRA_BCC, mccEmails.toArray());
    }
    return intent;
}

From source file:org.apache.cordova.EmailComposer.java

private void sendEmail(JSONObject parameters) {

    final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);

    // String callback = parameters.getString("callback");
    System.out.println(parameters.toString());

    boolean isHTML = false;
    try {/*from w w w  .  j a va2  s. com*/
        isHTML = parameters.getBoolean("bIsHTML");
    } catch (Exception e) {
        LOG.e("EmailComposer", "Error handling isHTML param: " + e.toString());
    }

    if (isHTML) {
        emailIntent.setType("text/html");
    } else {
        emailIntent.setType("text/plain");
    }

    // setting subject
    try {
        String subject = parameters.getString("subject");
        if (subject != null && subject.length() > 0) {
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
        }
    } catch (Exception e) {
        LOG.e("EmailComposer", "Error handling subject param: " + e.toString());
    }

    // setting body
    try {
        String body = parameters.getString("body");
        if (body != null && body.length() > 0) {
            if (isHTML) {
                emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body));
            } else {
                emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);
            }
        }
    } catch (Exception e) {
        LOG.e("EmailComposer", "Error handling body param: " + e.toString());
    }

    // setting TO recipients
    try {
        JSONArray toRecipients = parameters.getJSONArray("toRecipients");
        if (toRecipients != null && toRecipients.length() > 0) {
            String[] to = new String[toRecipients.length()];
            for (int i = 0; i < toRecipients.length(); i++) {
                to[i] = toRecipients.getString(i);
            }
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, to);
        }
    } catch (Exception e) {
        LOG.e("EmailComposer", "Error handling toRecipients param: " + e.toString());
    }

    // setting CC recipients
    try {
        JSONArray ccRecipients = parameters.getJSONArray("ccRecipients");
        if (ccRecipients != null && ccRecipients.length() > 0) {
            String[] cc = new String[ccRecipients.length()];
            for (int i = 0; i < ccRecipients.length(); i++) {
                cc[i] = ccRecipients.getString(i);
            }
            emailIntent.putExtra(android.content.Intent.EXTRA_CC, cc);
        }
    } catch (Exception e) {
        LOG.e("EmailComposer", "Error handling ccRecipients param: " + e.toString());
    }

    // setting BCC recipients
    try {
        JSONArray bccRecipients = parameters.getJSONArray("bccRecipients");
        if (bccRecipients != null && bccRecipients.length() > 0) {
            String[] bcc = new String[bccRecipients.length()];
            for (int i = 0; i < bccRecipients.length(); i++) {
                bcc[i] = bccRecipients.getString(i);
            }
            emailIntent.putExtra(android.content.Intent.EXTRA_BCC, bcc);
        }
    } catch (Exception e) {
        LOG.e("EmailComposer", "Error handling bccRecipients param: " + e.toString());
    }

    // setting attachments
    try {
        JSONArray attachments = parameters.getJSONArray("attachments");
        if (attachments != null && attachments.length() > 0) {
            ArrayList<Uri> uris = new ArrayList<Uri>();
            // convert from paths to Android friendly Parcelable Uri's
            for (int i = 0; i < attachments.length(); i++) {
                try {
                    File file = new File(attachments.getString(i));
                    if (file.exists()) {
                        Uri uri = Uri.fromFile(file);
                        uris.add(uri);
                    }
                } catch (Exception e) {
                    LOG.e("EmailComposer", "Error adding an attachment: " + e.toString());
                }
            }
            if (uris.size() > 0) {
                emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
            }
        }
    } catch (Exception e) {
        LOG.e("EmailComposer", "Error handling attachments param: " + e.toString());
    }

    this.cordova.startActivityForResult(this, emailIntent, 0);
}

From source file:de.appplant.cordova.plugin.emailcomposer.EmailComposer.java

/**
 * Setzt die BCC-Empfnger der Mail.//from   ww w  .  ja v  a 2s. c o  m
 */
private void setBccRecipients(JSONArray bccRecipients, Intent draft) throws JSONException {
    String[] receivers = new String[bccRecipients.length()];

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

    draft.putExtra(android.content.Intent.EXTRA_BCC, receivers);
}

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

/**
 * Setter for the bcc recipients.//from   w w w .j a  v a  2s .  c o  m
 *
 * @param recipients
 * List of email addresses.
 * @param draft
 * The intent to send.
 * @throws JSONException
 */
private void setBccRecipients(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_BCC, receivers);
}

From source file:com.pranavpandey.smallapp.sample.SmallAppSample.java

private void share() {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, R.string.app_name);
    intent.putExtra(Intent.EXTRA_BCC, "");
    intent.putExtra(Intent.EXTRA_TEXT, "Create advanced small apps for Sony devices with"
            + " Small App Support library.\n\n" + SOURCES_LINK);

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this).setTitle(R.string.sas_share)
            .setNegativeButton(android.R.string.cancel, null);

    new OpenIntentDialog(getContext(), intent, alertDialogBuilder, Type.LIST).setRememberSelection(true)
            .setActivityOpenListener(new OnActivityOpenListener() {
                public void onActivityOpen(ComponentName componentName) {
                    windowMinimize();//w w w .  j  a va 2  s. co  m
                }
            }).setExtraInfo(R.drawable.sas_ic_action_link, SOURCES_LINK, null).show(getRootView());
}

From source file:com.nexes.manager.EventHandler.java

/**
 * This method, handles the button presses of the top buttons found in the
 * Main activity.//from w w  w . j a v  a  2  s .c  o  m
 */
@Override
public void onClick(View v) {

    switch (v.getId()) {

    case R.id.back_button:
        if (mFileMang.getCurrentDir() != "/") {
            if (multi_select_flag) {
                mDelegate.killMultiSelect(true);
                Toast.makeText(mContext, "Multi-select is now off", Toast.LENGTH_SHORT).show();
            }

            stopThumbnailThread();
            updateDirectory(mFileMang.getPreviousDir());
            if (mPathLabel != null)
                mPathLabel.setText(mFileMang.getCurrentDir());
        }
        break;

    case R.id.home_button:
        if (multi_select_flag) {
            mDelegate.killMultiSelect(true);
            Toast.makeText(mContext, "Multi-select is now off", Toast.LENGTH_SHORT).show();
        }

        stopThumbnailThread();
        updateDirectory(mFileMang.setHomeDir("/sdcard"));
        if (mPathLabel != null)
            mPathLabel.setText(mFileMang.getCurrentDir());
        break;

    case R.id.info_button:
        Intent info = new Intent(mContext, DirectoryInfo.class);
        info.putExtra("PATH_NAME", mFileMang.getCurrentDir());
        mContext.startActivity(info);
        break;

    case R.id.help_button:
        Intent help = new Intent(mContext, HelpManager.class);
        mContext.startActivity(help);
        break;

    case R.id.manage_button:
        display_dialog(MANAGE_DIALOG);
        break;

    case R.id.multiselect_button:
        if (multi_select_flag) {
            mDelegate.killMultiSelect(true);

        } else {
            LinearLayout hidden_lay = (LinearLayout) ((Activity) mContext).findViewById(R.id.hidden_buttons);

            multi_select_flag = true;
            hidden_lay.setVisibility(LinearLayout.VISIBLE);
        }
        break;

    /*
     * three hidden buttons for multiselect
     */
    case R.id.hidden_attach:
        /* check if user selected objects before going further */
        if (mMultiSelectData == null || mMultiSelectData.isEmpty()) {
            mDelegate.killMultiSelect(true);
            break;
        }

        ArrayList<Uri> uris = new ArrayList<Uri>();
        int length = mMultiSelectData.size();
        Intent mail_int = new Intent();

        mail_int.setAction(android.content.Intent.ACTION_SEND_MULTIPLE);
        mail_int.setType("application/mail");
        mail_int.putExtra(Intent.EXTRA_BCC, "");
        mail_int.putExtra(Intent.EXTRA_SUBJECT, " ");

        for (int i = 0; i < length; i++) {
            File file = new File(mMultiSelectData.get(i));
            uris.add(Uri.fromFile(file));
        }

        mail_int.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
        mContext.startActivity(Intent.createChooser(mail_int, "Email using..."));

        mDelegate.killMultiSelect(true);
        break;

    case R.id.hidden_move:
    case R.id.hidden_copy:
        /* check if user selected objects before going further */
        if (mMultiSelectData == null || mMultiSelectData.isEmpty()) {
            mDelegate.killMultiSelect(true);
            break;
        }

        if (v.getId() == R.id.hidden_move)
            delete_after_copy = true;

        mInfoLabel.setText("Holding " + mMultiSelectData.size() + " file(s)");

        mDelegate.killMultiSelect(false);
        break;

    case R.id.hidden_delete:
        /* check if user selected objects before going further */
        if (mMultiSelectData == null || mMultiSelectData.isEmpty()) {
            mDelegate.killMultiSelect(true);
            break;
        }

        final String[] data = new String[mMultiSelectData.size()];
        int at = 0;

        for (String string : mMultiSelectData)
            data[at++] = string;

        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setMessage(
                "Are you sure you want to delete " + data.length + " files? This cannot be " + "undone.");
        builder.setCancelable(false);
        builder.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                new BackgroundWork(DELETE_TYPE).execute(data);
                mDelegate.killMultiSelect(true);
            }
        });
        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                mDelegate.killMultiSelect(true);
                dialog.cancel();
            }
        });

        builder.create().show();
        break;
    }
}

From source file:com.albedinsky.android.support.intent.EmailIntent.java

/**
 *//*from  ww w .  ja  v  a  2s  . com*/
@NonNull
@Override
protected Intent onBuild() {
    final Intent intent = new Intent(Intent.ACTION_SENDTO, createUri(mAddresses));
    intent.putExtra(Intent.EXTRA_SUBJECT, mSubject);
    intent.putExtra(Intent.EXTRA_TEXT, mMessage);
    if (mCcAddresses != null) {
        intent.putExtra(Intent.EXTRA_CC, addressesToArray(mCcAddresses));
    }
    if (mBccAddresses != null) {
        intent.putExtra(Intent.EXTRA_BCC, addressesToArray(mBccAddresses));
    }
    return intent;
}