Example usage for android.content Intent FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET

List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET

Introduction

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

Prototype

int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET

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

Click Source Link

Usage

From source file:com.google.samples.apps.iosched.session.SessionDetailFragment.java

private void displaySpeakersData(SessionDetailModel data) {
    final ViewGroup speakersGroup = (ViewGroup) getActivity().findViewById(R.id.session_speakers_block);

    // Remove all existing speakers (everything but first child, which is the header)
    for (int i = speakersGroup.getChildCount() - 1; i >= 1; i--) {
        speakersGroup.removeViewAt(i);// ww w .ja v  a2 s  . c om
    }

    final LayoutInflater inflater = getActivity().getLayoutInflater();

    boolean hasSpeakers = false;

    List<SessionDetailModel.Speaker> speakers = data.getSpeakers();

    for (final SessionDetailModel.Speaker speaker : speakers) {

        String speakerHeader = speaker.getName();
        if (!TextUtils.isEmpty(speaker.getCompany())) {
            speakerHeader += ", " + speaker.getCompany();
        }

        final View speakerView = inflater.inflate(R.layout.speaker_detail, speakersGroup, false);
        final TextView speakerHeaderView = (TextView) speakerView.findViewById(R.id.speaker_header);
        final ImageView speakerImageView = (ImageView) speakerView.findViewById(R.id.speaker_image);
        final TextView speakerAbstractView = (TextView) speakerView.findViewById(R.id.speaker_abstract);
        final ImageView plusOneIcon = (ImageView) speakerView.findViewById(R.id.gplus_icon_box);
        final ImageView twitterIcon = (ImageView) speakerView.findViewById(R.id.twitter_icon_box);

        setUpSpeakerSocialIcon(speaker, twitterIcon, speaker.getTwitterUrl(), UIUtils.TWITTER_COMMON_NAME,
                UIUtils.TWITTER_PACKAGE_NAME);

        setUpSpeakerSocialIcon(speaker, plusOneIcon, speaker.getPlusoneUrl(), UIUtils.GOOGLE_PLUS_COMMON_NAME,
                UIUtils.GOOGLE_PLUS_PACKAGE_NAME);

        // A speaker may have both a Twitter and GPlus page, only a Twitter page or only a
        // GPlus page, or neither. By default, align the Twitter icon to the right and the GPlus
        // icon to its left. If only a single icon is displayed, align it to the right.
        determineSocialIconPlacement(plusOneIcon, twitterIcon);

        if (!TextUtils.isEmpty(speaker.getImageUrl()) && mSpeakersImageLoader != null) {
            mSpeakersImageLoader.loadImage(speaker.getImageUrl(), speakerImageView);
        }

        speakerHeaderView.setText(speakerHeader);
        speakerImageView.setContentDescription(getString(R.string.speaker_googleplus_profile, speakerHeader));
        UIUtils.setTextMaybeHtml(speakerAbstractView, speaker.getAbstract());

        if (!TextUtils.isEmpty(speaker.getUrl())) {
            speakerImageView.setEnabled(true);
            speakerImageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent speakerProfileIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(speaker.getUrl()));
                    speakerProfileIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                    UIUtils.preferPackageForIntent(getActivity(), speakerProfileIntent,
                            UIUtils.GOOGLE_PLUS_PACKAGE_NAME);
                    startActivity(speakerProfileIntent);
                }
            });
        } else {
            speakerImageView.setEnabled(false);
            speakerImageView.setOnClickListener(null);
        }

        speakersGroup.addView(speakerView);
        hasSpeakers = true;
    }

    speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE);
    updateEmptyView(data);
}

From source file:com.google.android.apps.iosched.ui.SessionDetailFragment.java

private void updateLinksTab(Cursor cursor) {
    ViewGroup container = (ViewGroup) mRootView.findViewById(R.id.links_container);

    // Remove all views but the 'empty' view
    int childCount = container.getChildCount();
    if (childCount > 1) {
        container.removeViews(1, childCount - 1);
    }/*from w  w  w .j a  va 2  s .  c o  m*/

    LayoutInflater inflater = getLayoutInflater(null);

    boolean hasLinks = false;
    for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) {
        final String url = cursor.getString(SessionsQuery.LINKS_INDICES[i]);
        if (!TextUtils.isEmpty(url)) {
            hasLinks = true;
            ViewGroup linkContainer = (ViewGroup) inflater.inflate(R.layout.list_item_session_link, container,
                    false);
            ((TextView) linkContainer.findViewById(R.id.link_text)).setText(SessionsQuery.LINKS_TITLES[i]);
            final int linkTitleIndex = i;
            linkContainer.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    fireLinkEvent(SessionsQuery.LINKS_TITLES[linkTitleIndex]);
                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                    startActivity(intent);

                }
            });

            container.addView(linkContainer);

            // Create separator
            View separatorView = new ImageView(getActivity());
            separatorView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT));
            separatorView.setBackgroundResource(android.R.drawable.divider_horizontal_bright);
            container.addView(separatorView);
        }
    }

    container.findViewById(R.id.empty_links).setVisibility(hasLinks ? View.GONE : View.VISIBLE);
}

From source file:com.abewy.android.apps.klyph.app.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    /*//from w w  w.jav a 2  s . c o m
     * if (drawerToggle.onOptionsItemSelected(item))
     * {
     * return true;
     * }
     */

    if (item.getItemId() == android.R.id.home) {
        if (drawer.isDrawerOpen(Gravity.LEFT)) {
            drawer.closeDrawer(Gravity.LEFT);

            if (drawer.isDrawerOpen(Gravity.RIGHT))
                drawer.closeDrawer(Gravity.RIGHT);
        } else {
            drawer.openDrawer(Gravity.LEFT);

            if (drawer.isDrawerOpen(Gravity.RIGHT))
                drawer.closeDrawer(Gravity.RIGHT);
        }

        return true;
    } else if (item.getItemId() == R.id.menu_notifications) {
        if (drawer.isDrawerOpen(Gravity.RIGHT)) {
            drawer.closeDrawer(Gravity.RIGHT);

            if (drawer.isDrawerOpen(Gravity.LEFT))
                drawer.closeDrawer(Gravity.LEFT);
        } else {
            drawer.openDrawer(Gravity.RIGHT);

            if (drawer.isDrawerOpen(Gravity.LEFT))
                drawer.closeDrawer(Gravity.LEFT);
        }

        return true;
    } else if (item.getItemId() == R.id.menu_buy_pro) {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(KLYPH_PRO_PLAY_STORE_URI));
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        startActivity(intent);
    } else if (item.getItemId() == R.id.menu_logout) {
        AlertUtil.showAlert(this, R.string.menu_logout, R.string.logout_confirmation, R.string.ok,
                new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        logout();
                    }
                }, R.string.cancel, null);

        return true;
    } else if (item.getItemId() == R.id.menu_faq) {
        startActivity(new Intent(this, FaqActivity.class));
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.jimandreas.popularmovies.MovieDetailFragment.java

private Intent createShareForecastIntent() {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    shareIntent.setType("text/plain");
    if (mShareDetails == null) {
        shareIntent.putExtra(Intent.EXTRA_TEXT, "Sharing a favorite movie info...");
        return shareIntent;
    }//from  w w  w.j  a  va  2  s . c o m
    shareIntent.putExtra(Intent.EXTRA_TEXT, mShareDetails);
    return shareIntent;
}

From source file:com.irccloud.android.activity.VideoPlayerActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        finish();/*from  ww w . ja v a 2 s.  c o m*/
        overridePendingTransition(R.anim.fade_in, R.anim.slide_out_right);
        return true;
    } else if (item.getItemId() == R.id.action_download) {
        if (Build.VERSION.SDK_INT >= 16 && ActivityCompat.checkSelfPermission(this,
                Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE,
                    Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0);
        } else {
            DownloadManager d = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
            if (d != null) {
                String uri = getIntent().getDataString()
                        .replace(getResources().getString(R.string.VIDEO_SCHEME), "http");
                DownloadManager.Request r = new DownloadManager.Request(Uri.parse(uri));
                r.setDestinationInExternalPublicDir(Environment.DIRECTORY_MOVIES,
                        getIntent().getData().getLastPathSegment());
                r.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                r.allowScanningByMediaScanner();
                d.enqueue(r);
                Answers.getInstance().logShare(new ShareEvent().putContentType("Video").putMethod("Download"));
            }
        }
        return true;
    } else if (item.getItemId() == R.id.action_copy) {
        android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(
                CLIPBOARD_SERVICE);
        android.content.ClipData clip = android.content.ClipData.newRawUri("IRCCloud Video URL", Uri.parse(
                getIntent().getDataString().replace(getResources().getString(R.string.VIDEO_SCHEME), "http")));
        clipboard.setPrimaryClip(clip);
        Toast.makeText(VideoPlayerActivity.this, "Link copied to clipboard", Toast.LENGTH_SHORT).show();
        Answers.getInstance().logShare(new ShareEvent().putContentType("Video").putMethod("Copy to Clipboard"));
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && item.getItemId() == R.id.action_share) {
        Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse(
                getIntent().getDataString().replace(getResources().getString(R.string.VIDEO_SCHEME), "http")));
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT,
                getIntent().getDataString().replace(getResources().getString(R.string.VIDEO_SCHEME), "http"));
        intent.putExtra(ShareCompat.EXTRA_CALLING_PACKAGE, getPackageName());
        intent.putExtra(ShareCompat.EXTRA_CALLING_ACTIVITY,
                getPackageManager().getLaunchIntentForPackage(getPackageName()).getComponent());
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(Intent.createChooser(intent, "Share Video"));
        Answers.getInstance().logShare(new ShareEvent().putContentType("Video"));
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.android.email.activity.MessageView.java

/**
 * Handle clicks on sender, which shows {@link QuickContact} or prompts to add
 * the sender as a contact./*from  w ww .j  a va 2 s .com*/
 */
private void onClickSender() {
    // Bail early if message or sender not present
    if (mMessage == null)
        return;

    final Address senderEmail = Address.unpackFirst(mMessage.mFrom);
    if (senderEmail == null)
        return;

    // First perform lookup query to find existing contact
    final ContentResolver resolver = getContentResolver();
    final String address = senderEmail.getAddress();
    final Uri dataUri = Uri.withAppendedPath(CommonDataKinds.Email.CONTENT_FILTER_URI, Uri.encode(address));
    final Uri lookupUri = ContactsContract.Data.getContactLookupUri(resolver, dataUri);

    if (lookupUri != null) {
        // Found matching contact, trigger QuickContact
        QuickContact.showQuickContact(this, mSenderPresenceView, lookupUri, QuickContact.MODE_LARGE, null);
    } else {
        // No matching contact, ask user to create one
        final Uri mailUri = Uri.fromParts("mailto", address, null);
        final Intent intent = new Intent(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT, mailUri);

        // Pass along full E-mail string for possible create dialog
        intent.putExtra(ContactsContract.Intents.EXTRA_CREATE_DESCRIPTION, senderEmail.toString());

        // Only provide personal name hint if we have one
        final String senderPersonal = senderEmail.getPersonal();
        if (!TextUtils.isEmpty(senderPersonal)) {
            intent.putExtra(ContactsContract.Intents.Insert.NAME, senderPersonal);
        }
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);

        startActivity(intent);
    }
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.SessionDetailFragment.java

private void onSpeakersQueryComplete(Cursor cursor) {
    mSpeakersCursor = true;//  w w  w .j  av  a  2s. c  om
    final ViewGroup speakersGroup = (ViewGroup) mRootView.findViewById(R.id.session_speakers_block);

    // Remove all existing speakers (everything but first child, which is the header)
    for (int i = speakersGroup.getChildCount() - 1; i >= 1; i--) {
        speakersGroup.removeViewAt(i);
    }

    final LayoutInflater inflater = getActivity().getLayoutInflater();

    boolean hasSpeakers = false;

    while (cursor.moveToNext()) {
        final String speakerName = cursor.getString(SpeakersQuery.SPEAKER_NAME);
        if (TextUtils.isEmpty(speakerName)) {
            continue;
        }

        final String speakerImageUrl = cursor.getString(SpeakersQuery.SPEAKER_IMAGE_URL);
        final String speakerCompany = cursor.getString(SpeakersQuery.SPEAKER_COMPANY);
        final String speakerUrl = cursor.getString(SpeakersQuery.SPEAKER_URL);
        final String speakerAbstract = cursor.getString(SpeakersQuery.SPEAKER_ABSTRACT);

        String speakerHeader = speakerName;
        if (!TextUtils.isEmpty(speakerCompany)) {
            speakerHeader += ", " + speakerCompany;
        }

        final View speakerView = inflater.inflate(R.layout.speaker_detail, speakersGroup, false);
        final TextView speakerHeaderView = (TextView) speakerView.findViewById(R.id.speaker_header);
        final ImageView speakerImageView = (ImageView) speakerView.findViewById(R.id.speaker_image);
        final TextView speakerAbstractView = (TextView) speakerView.findViewById(R.id.speaker_abstract);

        if (!TextUtils.isEmpty(speakerImageUrl) && mImageLoader != null) {
            mImageLoader.get(UIUtils.getConferenceImageUrl(speakerImageUrl), speakerImageView);
        }

        speakerHeaderView.setText(speakerHeader);
        speakerImageView.setContentDescription(getString(R.string.speaker_googleplus_profile, speakerHeader));
        UIUtils.setTextMaybeHtml(speakerAbstractView, speakerAbstract);

        if (!TextUtils.isEmpty(speakerUrl)) {
            speakerImageView.setEnabled(true);
            speakerImageView.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent speakerProfileIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(speakerUrl));
                    speakerProfileIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                    UIUtils.preferPackageForIntent(getActivity(), speakerProfileIntent,
                            UIUtils.GOOGLE_PLUS_PACKAGE_NAME);
                    startActivity(speakerProfileIntent);
                }
            });
        } else {
            speakerImageView.setEnabled(false);
            speakerImageView.setOnClickListener(null);
        }

        speakersGroup.addView(speakerView);
        hasSpeakers = true;
        mHasSummaryContent = true;
    }

    speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE);

    // Show empty message when all data is loaded, and nothing to show
    if (mSessionCursor && !mHasSummaryContent) {
        mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE);
    }
}

From source file:com.coact.kochzap.CaptureActivity.java

private void handleDecodeExternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) {

    if (barcode != null) {
        viewfinderView.drawResultBitmap(barcode);
    }// w ww  .j a v a 2  s  . c  o  m

    long resultDurationMS;
    if (getIntent() == null) {
        resultDurationMS = Constants.DEFAULT_INTENT_RESULT_DURATION_MS;
    } else {
        resultDurationMS = getIntent().getLongExtra(Intents.Scan.RESULT_DISPLAY_DURATION_MS,
                Constants.DEFAULT_INTENT_RESULT_DURATION_MS);
    }

    if (resultDurationMS > 0) {
        String rawResultString = String.valueOf(rawResult);
        if (rawResultString.length() > 32) {
            rawResultString = rawResultString.substring(0, 32) + " ...";
        }
        statusView.setText(getString(resultHandler.getDisplayTitle()) + " : " + rawResultString);
    }

    maybeSetClipboard(resultHandler);

    if (source == IntentSource.NATIVE_APP_INTENT) {

        // Hand back whatever action they requested - this can be changed to Intents.Scan.ACTION when
        // the deprecated intent is retired.
        Intent intent = new Intent(getIntent().getAction());
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        intent.putExtra(Intents.Scan.RESULT, rawResult.toString());
        intent.putExtra(Intents.Scan.RESULT_FORMAT, rawResult.getBarcodeFormat().toString());
        byte[] rawBytes = rawResult.getRawBytes();
        if (rawBytes != null && rawBytes.length > 0) {
            intent.putExtra(Intents.Scan.RESULT_BYTES, rawBytes);
        }
        Map<ResultMetadataType, ?> metadata = rawResult.getResultMetadata();
        if (metadata != null) {
            if (metadata.containsKey(ResultMetadataType.UPC_EAN_EXTENSION)) {
                intent.putExtra(Intents.Scan.RESULT_UPC_EAN_EXTENSION,
                        metadata.get(ResultMetadataType.UPC_EAN_EXTENSION).toString());
            }
            Number orientation = (Number) metadata.get(ResultMetadataType.ORIENTATION);
            if (orientation != null) {
                intent.putExtra(Intents.Scan.RESULT_ORIENTATION, orientation.intValue());
            }
            String ecLevel = (String) metadata.get(ResultMetadataType.ERROR_CORRECTION_LEVEL);
            if (ecLevel != null) {
                intent.putExtra(Intents.Scan.RESULT_ERROR_CORRECTION_LEVEL, ecLevel);
            }
            @SuppressWarnings("unchecked")
            Iterable<byte[]> byteSegments = (Iterable<byte[]>) metadata.get(ResultMetadataType.BYTE_SEGMENTS);
            if (byteSegments != null) {
                int i = 0;
                for (byte[] byteSegment : byteSegments) {
                    intent.putExtra(Intents.Scan.RESULT_BYTE_SEGMENTS_PREFIX + i, byteSegment);
                    i++;
                }
            }
        }
        sendReplyMessage(R.id.return_scan_result, intent, resultDurationMS);

    } else if (source == IntentSource.PRODUCT_SEARCH_LINK) {

        // Reformulate the URL which triggered us into a query, so that the request goes to the same
        // TLD as the scan URL.
        int end = sourceUrl.lastIndexOf("/scan");
        String replyURL = sourceUrl.substring(0, end) + "?q=" + resultHandler.getDisplayContents()
                + "&source=zxing";
        sendReplyMessage(R.id.launch_product_query, replyURL, resultDurationMS);

    } else if (source == IntentSource.ZXING_LINK) {

        if (scanFromWebPageManager != null && scanFromWebPageManager.isScanFromWebPage()) {
            String replyURL = scanFromWebPageManager.buildReplyURL(rawResult, resultHandler);
            scanFromWebPageManager = null;
            sendReplyMessage(R.id.launch_product_query, replyURL, resultDurationMS);
        }

    }
}

From source file:net.oschina.app.v2.activity.zxing.CaptureActivity.java

private void handleDecodeExternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) {
    if (barcode != null) {
        viewfinderView.drawResultBitmap(barcode);
    }//from w  ww.ja va 2s  .c om

    long resultDurationMS;
    if (getIntent() == null) {
        resultDurationMS = DEFAULT_INTENT_RESULT_DURATION_MS;
    } else {
        resultDurationMS = getIntent().getLongExtra(Intents.Scan.RESULT_DISPLAY_DURATION_MS,
                DEFAULT_INTENT_RESULT_DURATION_MS);
    }

    if (resultDurationMS > 0) {
        String rawResultString = String.valueOf(rawResult);
        if (rawResultString.length() > 32) {
            rawResultString = rawResultString.substring(0, 32) + " ...";
        }
        statusView.setText(getString(resultHandler.getDisplayTitle()) + " : " + rawResultString);
    }

    if (copyToClipboard && !resultHandler.areContentsSecure()) {
        CharSequence text = resultHandler.getDisplayContents();
        ClipboardInterface.setText(text, this);
    }

    if (source == IntentSource.NATIVE_APP_INTENT) {

        // Hand back whatever action they requested - this can be changed to Intents.Scan.ACTION when
        // the deprecated intent is retired.
        Intent intent = new Intent(getIntent().getAction());
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        intent.putExtra(Intents.Scan.RESULT, rawResult.toString());
        intent.putExtra(Intents.Scan.RESULT_FORMAT, rawResult.getBarcodeFormat().toString());
        byte[] rawBytes = rawResult.getRawBytes();
        if (rawBytes != null && rawBytes.length > 0) {
            intent.putExtra(Intents.Scan.RESULT_BYTES, rawBytes);
        }
        Map<ResultMetadataType, ?> metadata = rawResult.getResultMetadata();
        if (metadata != null) {
            if (metadata.containsKey(ResultMetadataType.UPC_EAN_EXTENSION)) {
                intent.putExtra(Intents.Scan.RESULT_UPC_EAN_EXTENSION,
                        metadata.get(ResultMetadataType.UPC_EAN_EXTENSION).toString());
            }
            Number orientation = (Number) metadata.get(ResultMetadataType.ORIENTATION);
            if (orientation != null) {
                intent.putExtra(Intents.Scan.RESULT_ORIENTATION, orientation.intValue());
            }
            String ecLevel = (String) metadata.get(ResultMetadataType.ERROR_CORRECTION_LEVEL);
            if (ecLevel != null) {
                intent.putExtra(Intents.Scan.RESULT_ERROR_CORRECTION_LEVEL, ecLevel);
            }
            @SuppressWarnings("unchecked")
            Iterable<byte[]> byteSegments = (Iterable<byte[]>) metadata.get(ResultMetadataType.BYTE_SEGMENTS);
            if (byteSegments != null) {
                int i = 0;
                for (byte[] byteSegment : byteSegments) {
                    intent.putExtra(Intents.Scan.RESULT_BYTE_SEGMENTS_PREFIX + i, byteSegment);
                    i++;
                }
            }
        }
        sendReplyMessage(R.id.return_scan_result, intent, resultDurationMS);

    } else if (source == IntentSource.PRODUCT_SEARCH_LINK) {

        // Reformulate the URL which triggered us into a query, so that the request goes to the same
        // TLD as the scan URL.
        int end = sourceUrl.lastIndexOf("/scan");
        String replyURL = sourceUrl.substring(0, end) + "?q=" + resultHandler.getDisplayContents()
                + "&source=zxing";
        sendReplyMessage(R.id.launch_product_query, replyURL, resultDurationMS);

    } else if (source == IntentSource.ZXING_LINK) {

        if (scanFromWebPageManager != null && scanFromWebPageManager.isScanFromWebPage()) {
            String replyURL = scanFromWebPageManager.buildReplyURL(rawResult, resultHandler);
            scanFromWebPageManager = null;
            sendReplyMessage(R.id.launch_product_query, replyURL, resultDurationMS);
        }
    }
}

From source file:cn.suishen.email.activity.MessageViewFragmentBase.java

/**
 * Handle clicks on sender, which shows {@link QuickContact} or prompts to add
 * the sender as a contact.//w w w .j a  va2 s .c o m
 */
private void onClickSender() {
    if (!isMessageOpen())
        return;
    final Address senderEmail = Address.unpackFirst(mMessage.mFrom);
    if (senderEmail == null)
        return;

    if (mContactStatusState == CONTACT_STATUS_STATE_UNLOADED) {
        // Status not loaded yet.
        mContactStatusState = CONTACT_STATUS_STATE_UNLOADED_TRIGGERED;
        return;
    }
    if (mContactStatusState == CONTACT_STATUS_STATE_UNLOADED_TRIGGERED) {
        return; // Already clicked, and waiting for the data.
    }

    if (mQuickContactLookupUri != null) {
        QuickContact.showQuickContact(mContext, mFromBadge, mQuickContactLookupUri, QuickContact.MODE_MEDIUM,
                null);
    } else {
        // No matching contact, ask user to create one
        final Uri mailUri = Uri.fromParts("mailto", senderEmail.getAddress(), null);
        final Intent intent = new Intent(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT, mailUri);

        // Only provide personal name hint if we have one
        final String senderPersonal = senderEmail.getPersonal();
        if (!TextUtils.isEmpty(senderPersonal)) {
            intent.putExtra(ContactsContract.Intents.Insert.NAME, senderPersonal);
        }
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);

        startActivity(intent);
    }
}