urbanairship-core/src/main/java/com/urbanairship/ChannelCapture.java
private void attemptChannelCapture() {
        String channel = pushManager.getChannelId();

        // Only perform checks if notifications are enabled for the app.
        if (NotificationManagerCompat.from(context).areNotificationsEnabled()) {
            if (!this.configOptions.channelCaptureEnabled) {
                return;
            }

            if (UAirship.shared().getPushManager().isPushEnabled()
                    && this.preferenceDataStore.getLong(CHANNEL_CAPTURE_ENABLED_KEY, 0) < System.currentTimeMillis()) {
                this.preferenceDataStore.put(CHANNEL_CAPTURE_ENABLED_KEY, 0);
                return;
            }

            if (UAStringUtil.isEmpty(channel)) {
                return;
            }

            // Clipboard is null on a few VodaPhone devices
            if (clipboardManager == null) {
                return;
            }
        }

        String clipboardText = null;
        try {
            if (!clipboardManager.hasPrimaryClip()) {
                return;
            }

            ClipData primaryClip = clipboardManager.getPrimaryClip();

            if (primaryClip != null && primaryClip.getItemCount() > 0) {

                for (int i = 0; i < primaryClip.getItemCount(); i++) {
                    ClipData.Item item = primaryClip.getItemAt(i);
                    CharSequence text = item.getText();
                    if (text != null) {
                        clipboardText = text.toString();
                    }
                }
            }
        } catch (SecurityException e) {
            Logger.debug("Unable to read clipboard: " + e.getMessage());
            return;
        }

        String decodedClipboardString = UAStringUtil.base64DecodedString(clipboardText);
        String superSecretCode = generateToken();
        if (UAStringUtil.isEmpty(decodedClipboardString) || !decodedClipboardString.startsWith(superSecretCode)) {
            return;
        }

        // Perform the magic
        String url = null;
        if (decodedClipboardString.length() > superSecretCode.length()) {
            url = decodedClipboardString.replace(superSecretCode, GO_URL)
                                        .replace(CHANNEL_PLACEHOLDER, channel)
                                        .trim();
        }

        try {
            // Clear the clipboard
            clipboardManager.setPrimaryClip(ClipData.newPlainText("", ""));
        } catch (SecurityException e) {
            Logger.debug("Unable to clear clipboard: " + e.getMessage());
        }


        startChannelCaptureActivity(channel, url);
    }
/**
     * Checks the clipboard for the token and starts the activity if the token is
     * available.
     */
Checks the clipboard for the token and starts the activity if the token is
available.
Checks the clipboard for the token and starts the activity if the token is available .
private void attemptChannelCapture() {
        String channel = pushManager.getChannelId();
        if (NotificationManagerCompat.from(context).areNotificationsEnabled()) {
            if (!this.configOptions.channelCaptureEnabled) {
                return;
            }
            if (UAirship.shared().getPushManager().isPushEnabled()
                    && this.preferenceDataStore.getLong(CHANNEL_CAPTURE_ENABLED_KEY, 0) < System.currentTimeMillis()) {
                this.preferenceDataStore.put(CHANNEL_CAPTURE_ENABLED_KEY, 0);
                return;
            }
            if (UAStringUtil.isEmpty(channel)) {
                return;
            }
            if (clipboardManager == null) {
                return;
            }
        }
        String clipboardText = null;
        try {
            if (!clipboardManager.hasPrimaryClip()) {
                return;
            }
            ClipData primaryClip = clipboardManager.getPrimaryClip();
            if (primaryClip != null && primaryClip.getItemCount() > 0) {
                for (int i = 0; i < primaryClip.getItemCount(); i++) {
                    ClipData.Item item = primaryClip.getItemAt(i);
                    CharSequence text = item.getText();
                    if (text != null) {
                        clipboardText = text.toString();
                    }
                }
            }
        } catch (SecurityException e) {
            Logger.debug("Unable to read clipboard: " + e.getMessage());
            return;
        }
        String decodedClipboardString = UAStringUtil.base64DecodedString(clipboardText);
        String superSecretCode = generateToken();
        if (UAStringUtil.isEmpty(decodedClipboardString) || !decodedClipboardString.startsWith(superSecretCode)) {
            return;
        }
        String url = null;
        if (decodedClipboardString.length() > superSecretCode.length()) {
            url = decodedClipboardString.replace(superSecretCode, GO_URL)
                                        .replace(CHANNEL_PLACEHOLDER, channel)
                                        .trim();
        }
        try {
            clipboardManager.setPrimaryClip(ClipData.newPlainText("", ""));
        } catch (SecurityException e) {
            Logger.debug("Unable to clear clipboard: " + e.getMessage());
        }
        startChannelCaptureActivity(channel, url);
    }
private void attemptChannelCapture ( ) { String channel = pushManager . getChannelId ( ) ; if ( NotificationManagerCompat . from ( context ) . areNotificationsEnabled ( ) ) { if ( ! this . configOptions . channelCaptureEnabled ) { return ; } if ( UAirship . shared ( ) . getPushManager ( ) . isPushEnabled ( ) && this . preferenceDataStore . getLong ( CHANNEL_CAPTURE_ENABLED_KEY , 0 ) < System . currentTimeMillis ( ) ) { this . preferenceDataStore . put ( CHANNEL_CAPTURE_ENABLED_KEY , 0 ) ; return ; } if ( UAStringUtil . isEmpty ( channel ) ) { return ; } if ( clipboardManager == null ) { return ; } } String clipboardText = null ; try { if ( ! clipboardManager . hasPrimaryClip ( ) ) { return ; } ClipData primaryClip = clipboardManager . getPrimaryClip ( ) ; if ( primaryClip != null && primaryClip . getItemCount ( ) > 0 ) { for ( int i = 0 ; i < primaryClip . getItemCount ( ) ; i ++ ) { ClipData . Item item = primaryClip . getItemAt ( i ) ; CharSequence text = item . getText ( ) ; if ( text != null ) { clipboardText = text . toString ( ) ; } } } } catch ( SecurityException e ) { Logger . debug ( "Unable to read clipboard: " + e . getMessage ( ) ) ; return ; } String decodedClipboardString = UAStringUtil . base64DecodedString ( clipboardText ) ; String superSecretCode = generateToken ( ) ; if ( UAStringUtil . isEmpty ( decodedClipboardString ) || ! decodedClipboardString . startsWith ( superSecretCode ) ) { return ; } String url = null ; if ( decodedClipboardString . length ( ) > superSecretCode . length ( ) ) { url = decodedClipboardString . replace ( superSecretCode , GO_URL ) . replace ( CHANNEL_PLACEHOLDER , channel ) . trim ( ) ; } try { clipboardManager . setPrimaryClip ( ClipData . newPlainText ( "" , "" ) ) ; } catch ( SecurityException e ) { Logger . debug ( "Unable to clear clipboard: " + e . getMessage ( ) ) ; } startChannelCaptureActivity ( channel , url ) ; }
Checks the clipboard for the token and starts the activity if the token is
 available.
Checks the clipboard for the token and starts the activity if the token is available .
// Only perform checks if notifications are enabled for the app. // Clipboard is null on a few VodaPhone devices // Perform the magic // Clear the clipboard