Example usage for android.content Intent ACTION_SEND

List of usage examples for android.content Intent ACTION_SEND

Introduction

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

Prototype

String ACTION_SEND

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

Click Source Link

Document

Activity Action: Deliver some data to someone else.

Usage

From source file:com.aimfire.gallery.GalleryActivity.java

/**
 * share only to certain apps. code based on "http://stackoverflow.com/questions/
 * 9730243/how-to-filter-specific-apps-for-action-send-intent-and-set-a-different-
 * text-for/18980872#18980872"//from   w w  w.j a  v a 2  s  . com
 * 
 * "copy link" inspired by http://cketti.de/2016/06/15/share-url-to-clipboard/
 * 
 * in general, "deep linking" is supported by the apps below. Facebook, Wechat,
 * Telegram are exceptions. click on the link would bring users to the landing
 * page. 
 * 
 * Facebook doesn't take our EXTRA_TEXT so user will have to "copy link" first 
 * then paste the link
 */
private void shareMedia(Intent data) {
    /*
     * we log this as "share complete", but user can still cancel the share at this point,
     * and we wouldn't be able to know
     */
    mFirebaseAnalytics.logEvent(MainConsts.FIREBASE_CUSTOM_EVENT_SHARE_COMPLETE, null);

    Resources resources = getResources();

    /*
     * get the resource id for the shared file
     */
    String id = data.getStringExtra(MainConsts.EXTRA_ID_RESOURCE);

    /*
     * construct link
     */
    String link = "https://" + resources.getString(R.string.app_domain) + "/?id=" + id + "&name="
            + ((mPreviewName != null) ? mPreviewName : mMediaName);

    /*
     * message subject and text
     */
    String emailSubject, emailText, twitterText;

    if (MediaScanner.isPhoto(mMediaPath)) {
        emailSubject = resources.getString(R.string.emailSubjectPhoto);
        emailText = resources.getString(R.string.emailBodyPhotoPrefix) + link;
        twitterText = resources.getString(R.string.emailBodyPhotoPrefix) + link
                + resources.getString(R.string.twitterHashtagPhoto) + resources.getString(R.string.app_hashtag);
    } else if (MediaScanner.is3dMovie(mMediaPath)) {
        emailSubject = resources.getString(R.string.emailSubjectVideo);
        emailText = resources.getString(R.string.emailBodyVideoPrefix) + link;
        twitterText = resources.getString(R.string.emailBodyVideoPrefix) + link
                + resources.getString(R.string.twitterHashtagVideo) + resources.getString(R.string.app_hashtag);
    } else //if(MediaScanner.is2dMovie(mMediaPath))
    {
        emailSubject = resources.getString(R.string.emailSubjectVideo2d);
        emailText = resources.getString(R.string.emailBodyVideoPrefix2d) + link;
        twitterText = resources.getString(R.string.emailBodyVideoPrefix2d) + link
                + resources.getString(R.string.twitterHashtagVideo) + resources.getString(R.string.app_hashtag);
    }

    Intent emailIntent = new Intent();
    emailIntent.setAction(Intent.ACTION_SEND);
    // Native email client doesn't currently support HTML, but it doesn't hurt to try in case they fix it
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, emailSubject);
    emailIntent.putExtra(Intent.EXTRA_TEXT, emailText);
    //emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(resources.getString(R.string.share_email_native)));
    emailIntent.setType("message/rfc822");

    PackageManager pm = getPackageManager();
    Intent sendIntent = new Intent(Intent.ACTION_SEND);
    sendIntent.setType("text/plain");

    Intent openInChooser = Intent.createChooser(emailIntent, resources.getString(R.string.share_chooser_text));

    List<ResolveInfo> resInfo = pm.queryIntentActivities(sendIntent, 0);
    List<LabeledIntent> intentList = new ArrayList<LabeledIntent>();
    for (int i = 0; i < resInfo.size(); i++) {
        // Extract the label, append it, and repackage it in a LabeledIntent
        ResolveInfo ri = resInfo.get(i);
        String packageName = ri.activityInfo.packageName;
        if (packageName.contains("android.email")) {
            emailIntent.setPackage(packageName);
        } else if (packageName.contains("twitter") || packageName.contains("facebook")
                || packageName.contains("whatsapp") || packageName.contains("tencent.mm") || //wechat
                packageName.contains("line") || packageName.contains("skype") || packageName.contains("viber")
                || packageName.contains("kik") || packageName.contains("sgiggle") || //tango
                packageName.contains("kakao") || packageName.contains("telegram")
                || packageName.contains("nimbuzz") || packageName.contains("hike")
                || packageName.contains("imoim") || packageName.contains("bbm")
                || packageName.contains("threema") || packageName.contains("mms")
                || packageName.contains("android.apps.messaging") || //google messenger
                packageName.contains("android.talk") || //google hangouts
                packageName.contains("android.gm")) {
            Intent intent = new Intent();
            intent.setComponent(new ComponentName(packageName, ri.activityInfo.name));
            intent.setAction(Intent.ACTION_SEND);
            intent.setType("text/plain");
            if (packageName.contains("twitter")) {
                intent.putExtra(Intent.EXTRA_TEXT, twitterText);
            } else if (packageName.contains("facebook")) {
                /*
                 * the warning below is wrong! at least on GS5, Facebook client does take
                 * our text, however it seems it takes only the first hyperlink in the
                 * text.
                 * 
                 * Warning: Facebook IGNORES our text. They say "These fields are intended 
                 * for users to express themselves. Pre-filling these fields erodes the 
                 * authenticity of the user voice."
                 * One workaround is to use the Facebook SDK to post, but that doesn't 
                 * allow the user to choose how they want to share. We can also make a 
                 * custom landing page, and the link will show the <meta content ="..."> 
                 * text from that page with our link in Facebook.
                 */
                intent.putExtra(Intent.EXTRA_TEXT, link);
            } else if (packageName.contains("tencent.mm")) //wechat
            {
                /*
                 * wechat appears to do this similar to Facebook
                 */
                intent.putExtra(Intent.EXTRA_TEXT, link);
            } else if (packageName.contains("android.gm")) {
                // If Gmail shows up twice, try removing this else-if clause and the reference to "android.gm" above
                intent.putExtra(Intent.EXTRA_SUBJECT, emailSubject);
                intent.putExtra(Intent.EXTRA_TEXT, emailText);
                //intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(resources.getString(R.string.share_email_gmail)));
                intent.setType("message/rfc822");
            } else if (packageName.contains("android.apps.docs")) {
                /*
                 * google drive - no reason to send link to it
                 */
                continue;
            } else {
                intent.putExtra(Intent.EXTRA_TEXT, emailText);
            }

            intentList.add(new LabeledIntent(intent, packageName, ri.loadLabel(pm), ri.icon));
        }
    }

    /*
     *  create "Copy Link To Clipboard" Intent
     */
    Intent clipboardIntent = new Intent(this, CopyToClipboardActivity.class);
    clipboardIntent.setData(Uri.parse(link));
    intentList.add(new LabeledIntent(clipboardIntent, getPackageName(),
            getResources().getString(R.string.clipboard_activity_name), R.drawable.ic_copy_link));

    // convert intentList to array
    LabeledIntent[] extraIntents = intentList.toArray(new LabeledIntent[intentList.size()]);

    openInChooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents);
    startActivity(openInChooser);
}

From source file:org.planetmono.dcuploader.ActivityUploader.java

@SuppressWarnings("unchecked")
@Override/*from  w ww  .j  a va2 s.co  m*/
public void onCreate(Bundle savedState) {
    super.onCreate(savedState);

    initViews();
    if (formLocation)
        queryLocation(true);

    if (savedState != null) {
        if (savedState.containsKey("tempfile"))
            tempFile = new File(savedState.getString("tempfile"));
        if (savedState.containsKey("target"))
            resolveTarget(savedState.getString("target"));
        if (savedState.containsKey("tempfiles"))
            tempFiles = savedState.getStringArrayList("tempfiles");
        if (savedState.containsKey("contents")) {
            contents = new ArrayList<Uri>();
            String[] carr = savedState.getStringArray("contents");
            for (String s : carr)
                contents.add(Uri.parse(s));
        }
    }

    postfix = "from <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>";

    Button uploadVisit = (Button) findViewById(R.id.upload_visit);
    if (passThrough || target == null)
        uploadVisit.setEnabled(false);
    else
        uploadVisit.setEnabled(true);

    /* populate data by getting STREAM parameter */
    Intent i = getIntent();
    Bundle b = i.getExtras();
    String action = i.getAction();

    if (action.equals(Intent.ACTION_SEND) || action.equals(Intent.ACTION_SEND_MULTIPLE)) {
        called = true;

        if (i.hasExtra(Intent.EXTRA_STREAM)) {
            Object o = b.get(Intent.EXTRA_STREAM);

            /* quick and dirty. any better idea? */
            try {
                contents.add((Uri) o);
            } catch (Exception e1) {
                try {
                    contents = (ArrayList<Uri>) ((ArrayList<Uri>) o).clone();
                } catch (Exception e2) {
                }
            }

            boolean exceeded = false;
            if (contents.size() > 5) {
                exceeded = true;

                do {
                    contents.remove(5);
                } while (contents.size() > 5);
            }

            galleryChanged = true;

            updateImageButtons();
            resetThumbnails();
            updateGallery();

            if (exceeded)
                Toast.makeText(this,
                        " 5  . 5 ??? ? ?.",
                        Toast.LENGTH_LONG).show();
        }
        if (i.hasExtra(Intent.EXTRA_TEXT)) {
            ((EditText) findViewById(R.id.upload_text)).setText(b.getString(Intent.EXTRA_TEXT));
        }
    } else if (action.equals("share")) {
        called = true;
        /* HTC web browser uses non-standard intent */

        ((EditText) findViewById(R.id.upload_text)).setText(b.getString(Intent.EXTRA_TITLE));
    } else if (action.equals(Intent.ACTION_VIEW)) {
        Uri uri = i.getData();

        if (i.getCategories().contains(Intent.CATEGORY_BROWSABLE)) {
            passThrough = true;

            Pattern p = Pattern.compile("id=([\\-a-zA-Z0-9_]+)");
            Matcher m = p.matcher(uri.toString());

            if (m.find()) {
                resolveTarget(m.group(1));
            } else {
                passThrough = false;
            }

            if (uri.getHost().equals(Application.HOST_DCMYS)) {
                destination = Application.DESTINATION_DCMYS;
                postfix = "from dc.m.dcmys.kr w/ <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>";
            } else if (uri.getHost().equals(Application.HOST_MOOLZO)) {
                destination = Application.DESTINATION_MOOLZO;
                postfix = "- From m.oolzo.com w/ <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>";
            } else if (uri.getHost().equals(Application.HOST_DCINSIDE)) {
                destination = Application.DESTINATION_DCINSIDE;
            }

            setDefaultImage();
        }
    }

    reloadConfigurations();
}

From source file:com.amaze.filemanager.fragments.MainFragment.java

/**
 * Returns the intent with uri corresponding to specific {@link HybridFileParcelable} back to external app
 *//*ww w .  ja  v  a  2  s . c  o m*/
public void returnIntentResults(HybridFileParcelable baseFile) {

    getMainActivity().mReturnIntent = false;

    Intent intent = new Intent();
    if (getMainActivity().mRingtonePickerIntent) {

        Uri mediaStoreUri = MediaStoreHack.getUriFromFile(baseFile.getPath(), getActivity());
        Log.d(getClass().getSimpleName(), mediaStoreUri.toString() + "\t"
                + MimeTypes.getMimeType(baseFile.getPath(), baseFile.isDirectory()));
        intent.setDataAndType(mediaStoreUri, MimeTypes.getMimeType(baseFile.getPath(), baseFile.isDirectory()));
        intent.putExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI, mediaStoreUri);
        getActivity().setResult(FragmentActivity.RESULT_OK, intent);
        getActivity().finish();
    } else {

        Log.d("pickup", "file");

        Intent intentresult = new Intent();

        Uri resultUri = Utils.getUriForBaseFile(getActivity(), baseFile);
        intentresult.setAction(Intent.ACTION_SEND);
        intentresult.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

        if (resultUri != null)
            intentresult.setDataAndType(resultUri, MimeTypes.getExtension(baseFile.getPath()));

        getActivity().setResult(FragmentActivity.RESULT_OK, intentresult);
        getActivity().finish();
        //mode.finish();
    }
}

From source file:com.hivewallet.androidclient.wallet.ui.WalletActivity.java

private boolean archiveWalletBackup(@Nonnull final File file) {
    Uri shareableUri = null;/*from ww  w . j  a va  2 s .c o  m*/
    try {
        shareableUri = FileProvider.getUriForFile(this, Constants.FILE_PROVIDER_AUTHORITY, file);
    } catch (IllegalArgumentException e) {
        throw new RuntimeException("Backup file cannot be shared", e);
    }

    log.info("Shareable URI: {}", shareableUri);

    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.export_keys_dialog_mail_subject));
    intent.putExtra(Intent.EXTRA_TEXT,
            getString(R.string.export_keys_dialog_mail_text) + "\n\n"
                    + String.format(Constants.WEBMARKET_APP_URL, getPackageName()) + "\n\n"
                    + Constants.SOURCE_URL + '\n');
    intent.setType(Constants.MIMETYPE_WALLET_BACKUP);
    intent.putExtra(Intent.EXTRA_STREAM, shareableUri);
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    try {
        startActivity(Intent.createChooser(intent, getString(R.string.export_keys_dialog_mail_intent_chooser)));
        log.info("invoked chooser for archiving wallet backup");
        return true;
    } catch (final Exception x) {
        longToast(R.string.export_keys_dialog_mail_intent_failed);
        log.error("archiving wallet backup failed", x);
        return false;
    }
}

From source file:com.nttec.everychan.ui.presentation.BoardFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    //?  ? -/*w w w  .ja va  2s .com*/
    switch (item.getItemId()) {
    case R.id.context_menu_thumb_load_thumb:
        bitmapCache.asyncGet(
                ChanModels.hashAttachmentModel((AttachmentModel) lastContextMenuAttachment.getTag()),
                ((AttachmentModel) lastContextMenuAttachment.getTag()).thumbnail,
                resources.getDimensionPixelSize(R.dimen.post_thumbnail_size), chan, null, imagesDownloadTask,
                (ImageView) lastContextMenuAttachment.findViewById(R.id.post_thumbnail_image),
                imagesDownloadExecutor, Async.UI_HANDLER, true, R.drawable.thumbnail_error);
        return true;
    case R.id.context_menu_thumb_download:
        downloadFile((AttachmentModel) lastContextMenuAttachment.getTag());
        return true;
    case R.id.context_menu_thumb_copy_url:
        String url = chan.fixRelativeUrl(((AttachmentModel) lastContextMenuAttachment.getTag()).path);
        Clipboard.copyText(activity, url);
        Toast.makeText(activity, resources.getString(R.string.notification_url_copied, url), Toast.LENGTH_LONG)
                .show();
        return true;
    case R.id.context_menu_thumb_attachment_info:
        String info = Attachments.getAttachmentInfoString(chan,
                ((AttachmentModel) lastContextMenuAttachment.getTag()), resources);
        Toast.makeText(activity, info, Toast.LENGTH_LONG).show();
        return true;
    case R.id.context_menu_thumb_reverse_search:
        ReverseImageSearch.openDialog(activity,
                chan.fixRelativeUrl(((AttachmentModel) lastContextMenuAttachment.getTag()).path));
        return true;
    }

    //?  ?  ?
    int position = lastContextMenuPosition;
    if (item.getMenuInfo() != null && item.getMenuInfo() instanceof AdapterView.AdapterContextMenuInfo) {
        position = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position;
    }
    if (nullAdapterIsSet || position == -1 || adapter.getCount() <= position)
        return false;
    switch (item.getItemId()) {
    case R.id.context_menu_open_in_new_tab:
        UrlPageModel modelNewTab = new UrlPageModel();
        modelNewTab.chanName = chan.getChanName();
        modelNewTab.type = UrlPageModel.TYPE_THREADPAGE;
        modelNewTab.boardName = tabModel.pageModel.boardName;
        modelNewTab.threadNumber = adapter.getItem(position).sourceModel.parentThread;
        String tabTitle = null;
        String subject = adapter.getItem(position).sourceModel.subject;
        if (subject != null && subject.length() != 0) {
            tabTitle = subject;
        } else {
            Spanned spannedComment = adapter.getItem(position).spannedComment;
            if (spannedComment != null) {
                tabTitle = spannedComment.toString().replace('\n', ' ');
                if (tabTitle.length() > MAX_TITLE_LENGHT)
                    tabTitle = tabTitle.substring(0, MAX_TITLE_LENGHT);
            }
        }
        if (tabTitle != null)
            tabTitle = resources.getString(R.string.tabs_title_threadpage_loaded, modelNewTab.boardName,
                    tabTitle);
        UrlHandler.open(modelNewTab, activity, false, tabTitle);
        return true;
    case R.id.context_menu_thread_preview:
        showThreadPreviewDialog(position);
        return true;
    case R.id.context_menu_reply_no_reading:
        UrlPageModel model = new UrlPageModel();
        model.chanName = chan.getChanName();
        model.type = UrlPageModel.TYPE_THREADPAGE;
        model.boardName = tabModel.pageModel.boardName;
        model.threadNumber = adapter.getItem(position).sourceModel.parentThread;
        openPostForm(ChanModels.hashUrlPageModel(model), presentationModel.source.boardModel,
                getSendPostModel(model));
        return true;
    case R.id.context_menu_hide:
        adapter.getItem(position).hidden = true;
        database.addHidden(tabModel.pageModel.chanName, tabModel.pageModel.boardName,
                pageType == TYPE_POSTSLIST ? tabModel.pageModel.threadNumber
                        : adapter.getItem(position).sourceModel.number,
                pageType == TYPE_POSTSLIST ? adapter.getItem(position).sourceModel.number : null);
        adapter.notifyDataSetChanged();
        return true;
    case R.id.context_menu_reply:
        openReply(position, false, null);
        return true;
    case R.id.context_menu_reply_with_quote:
        openReply(position, true, null);
        return true;
    case R.id.context_menu_select_text:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && lastContextMenuPosition == -1) {
            int firstPosition = listView.getFirstVisiblePosition() - listView.getHeaderViewsCount();
            int wantedChild = position - firstPosition;
            if (wantedChild >= 0 && wantedChild < listView.getChildCount()) {
                View v = listView.getChildAt(wantedChild);
                if (v != null && v.getTag() != null && v.getTag() instanceof PostsListAdapter.PostViewTag) {
                    ((PostsListAdapter.PostViewTag) v.getTag()).commentView.startSelection();
                    return true;
                }
            }
        }
        Clipboard.copyText(activity, adapter.getItem(position).spannedComment.toString());
        Toast.makeText(activity, resources.getString(R.string.notification_comment_copied), Toast.LENGTH_LONG)
                .show();
        return true;
    case R.id.context_menu_share:
        UrlPageModel sharePostUrlPageModel = new UrlPageModel();
        sharePostUrlPageModel.chanName = chan.getChanName();
        sharePostUrlPageModel.type = UrlPageModel.TYPE_THREADPAGE;
        sharePostUrlPageModel.boardName = tabModel.pageModel.boardName;
        sharePostUrlPageModel.threadNumber = tabModel.pageModel.threadNumber;
        sharePostUrlPageModel.postNumber = adapter.getItem(position).sourceModel.number;

        Intent sharePostIntent = new Intent(Intent.ACTION_SEND);
        sharePostIntent.setType("text/plain");
        sharePostIntent.putExtra(Intent.EXTRA_SUBJECT, chan.buildUrl(sharePostUrlPageModel));
        sharePostIntent.putExtra(Intent.EXTRA_TEXT, adapter.getItem(position).spannedComment.toString());
        startActivity(Intent.createChooser(sharePostIntent, resources.getString(R.string.share_via)));
        return true;
    case R.id.context_menu_delete:
        DeletePostModel delModel = new DeletePostModel();
        delModel.chanName = chan.getChanName();
        delModel.boardName = tabModel.pageModel.boardName;
        delModel.threadNumber = tabModel.pageModel.threadNumber;
        delModel.postNumber = adapter.getItem(position).sourceModel.number;
        runDelete(delModel, adapter.getItem(position).sourceModel.attachments != null
                && adapter.getItem(position).sourceModel.attachments.length > 0);
        return true;
    case R.id.context_menu_report:
        DeletePostModel reportModel = new DeletePostModel();
        reportModel.chanName = chan.getChanName();
        reportModel.boardName = tabModel.pageModel.boardName;
        reportModel.threadNumber = tabModel.pageModel.threadNumber;
        reportModel.postNumber = adapter.getItem(position).sourceModel.number;
        runReport(reportModel);
        return true;
    case R.id.context_menu_subscribe:
        String chanName = chan.getChanName();
        String board = tabModel.pageModel.boardName;
        String thread = tabModel.pageModel.threadNumber;
        String post = adapter.getItem(position).sourceModel.number;
        if (subscriptions.hasSubscription(chanName, board, thread, post)) {
            subscriptions.removeSubscription(chanName, board, thread, post);
            for (int i = position; i < adapter.getCount(); ++i)
                adapter.getItem(i).onUnsubscribe(post);
        } else {
            subscriptions.addSubscription(chanName, board, thread, post);
            for (int i = position; i < adapter.getCount(); ++i)
                adapter.getItem(i).onSubscribe(post);
        }
        adapter.notifyDataSetChanged();
        return true;
    }
    return false;
}

From source file:com.android.contacts.list.DefaultContactBrowseListFragment.java

/**
 * Share all contacts that are currently selected. This method is pretty inefficient for
 * handling large numbers of contacts. I don't expect this to be a problem.
 *///  w  ww  .  j  a v a  2  s.  c  om
private void shareSelectedContacts() {
    final StringBuilder uriListBuilder = new StringBuilder();
    for (Long contactId : getSelectedContactIds()) {
        final Uri contactUri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, contactId);
        final Uri lookupUri = ContactsContract.Contacts.getLookupUri(getContext().getContentResolver(),
                contactUri);
        if (lookupUri == null) {
            continue;
        }
        final List<String> pathSegments = lookupUri.getPathSegments();
        if (pathSegments.size() < 2) {
            continue;
        }
        final String lookupKey = pathSegments.get(pathSegments.size() - 2);
        if (uriListBuilder.length() > 0) {
            uriListBuilder.append(':');
        }
        uriListBuilder.append(Uri.encode(lookupKey));
    }
    if (uriListBuilder.length() == 0) {
        return;
    }
    final Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_MULTI_VCARD_URI,
            Uri.encode(uriListBuilder.toString()));
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType(ContactsContract.Contacts.CONTENT_VCARD_TYPE);
    intent.putExtra(Intent.EXTRA_STREAM, uri);
    try {
        startActivityForResult(Intent.createChooser(intent, getResources()
                .getQuantityString(R.plurals.title_share_via, /* quantity */ getSelectedContactIds().size())),
                ACTIVITY_REQUEST_CODE_SHARE);
    } catch (final ActivityNotFoundException ex) {
        Toast.makeText(getContext(), R.string.share_error, Toast.LENGTH_SHORT).show();
    }
}

From source file:com.javielinux.utils.Utils.java

public static void sendLastCrash(Activity cnt) {
    try {/* w  w  w  . j  a  v  a  2  s .  c o  m*/
        Intent gmail = new Intent(Intent.ACTION_VIEW);
        gmail.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
        gmail.putExtra(Intent.EXTRA_EMAIL, new String[] { cnt.getString(R.string.email_send_errors) });
        gmail.setData(Uri.parse(cnt.getString(R.string.email_send_errors)));
        gmail.putExtra(Intent.EXTRA_SUBJECT, "TweetTopics crash");
        gmail.setType("plain/text");
        gmail.putExtra(Intent.EXTRA_TEXT, ErrorReporter.getErrors(cnt));
        cnt.startActivity(gmail);
    } catch (ActivityNotFoundException e) {
        Intent msg = new Intent(Intent.ACTION_SEND);
        msg.putExtra(Intent.EXTRA_EMAIL, new String[] { cnt.getString(R.string.email_send_errors) });
        msg.putExtra(Intent.EXTRA_SUBJECT, "TweetTopics crash");
        msg.setType("plain/text");
        msg.putExtra(Intent.EXTRA_TEXT, ErrorReporter.getErrors(cnt));
        cnt.startActivity(msg);
    }
}

From source file:com.kncwallet.wallet.ui.WalletActivity.java

private void mailPrivateKeys(@Nonnull final File file) {
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.export_keys_dialog_mail_subject));
    intent.putExtra(Intent.EXTRA_TEXT,//from  www .j a  v  a  2  s. co m
            getString(R.string.export_keys_dialog_mail_text) + "\n\n"
                    + String.format(Constants.WEBMARKET_APP_URL, getPackageName()) + "\n\n"
                    + Constants.SOURCE_URL + '\n');
    intent.setType("x-bitcoin/private-keys");
    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
    startActivity(Intent.createChooser(intent, getString(R.string.export_keys_dialog_mail_intent_chooser)));

    log.info("invoked archive private keys chooser");
}

From source file:com.lgallardo.qbittorrentclient.RefreshListener.java

public void emailReport() {

    if (CustomLogger.isMainActivityReporting()) {

        Intent emailIntent = new Intent(Intent.ACTION_SEND);

        emailIntent.setType("text/plain");

        emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "lgallard+qbcontroller@gmail.com" });
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "qBittorrentController report");

        // Include report
        emailIntent.putExtra(Intent.EXTRA_TEXT, CustomLogger.getReport());

        // Delete report
        CustomLogger.setMainActivityReporting(false);
        CustomLogger.deleteMainReport();
        CustomLogger.deleteNotifierReport();

        // Launch email chooser
        startActivity(Intent.createChooser(emailIntent, "Send qBittorrent report..."));

        // Reporting - Finish report
        CustomLogger.setMainActivityReporting(false);

    }/*w  ww. j a v  a2 s  . c o m*/

}

From source file:com.edible.ocr.CaptureActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    ClipboardManager clipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    switch (item.getItemId()) {

    case OPTIONS_COPY_RECOGNIZED_TEXT_ID:
        clipboardManager.setText(ocrResultView.getText());
        if (clipboardManager.hasText()) {
            Toast toast = Toast.makeText(this, "Text copied.", Toast.LENGTH_LONG);
            toast.setGravity(Gravity.BOTTOM, 0, 0);
            toast.show();/*from w ww  . j ava2 s.c o  m*/
        }
        return true;
    case OPTIONS_SHARE_RECOGNIZED_TEXT_ID:
        Intent shareRecognizedTextIntent = new Intent(android.content.Intent.ACTION_SEND);
        shareRecognizedTextIntent.setType("text/plain");
        shareRecognizedTextIntent.putExtra(android.content.Intent.EXTRA_TEXT, ocrResultView.getText());
        startActivity(Intent.createChooser(shareRecognizedTextIntent, "Share via"));
        return true;
    case OPTIONS_COPY_TRANSLATED_TEXT_ID:
        clipboardManager.setText(translationView.getText());
        if (clipboardManager.hasText()) {
            Toast toast = Toast.makeText(this, "Text copied.", Toast.LENGTH_LONG);
            toast.setGravity(Gravity.BOTTOM, 0, 0);
            toast.show();
        }
        return true;
    case OPTIONS_SHARE_TRANSLATED_TEXT_ID:
        Intent shareTranslatedTextIntent = new Intent(android.content.Intent.ACTION_SEND);
        shareTranslatedTextIntent.setType("text/plain");
        shareTranslatedTextIntent.putExtra(android.content.Intent.EXTRA_TEXT, translationView.getText());
        startActivity(Intent.createChooser(shareTranslatedTextIntent, "Share via"));
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}