Example usage for android.content Intent getIntExtra

List of usage examples for android.content Intent getIntExtra

Introduction

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

Prototype

public int getIntExtra(String name, int defaultValue) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.clearbon.cordova.netswipe.NetSwipePlugin.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == NetswipeSDK.REQUEST_CODE) {
        /*ArrayList<String> scanAttempts = 
        data.getStringArrayListExtra(NetswipeSDK.EXTRA_SCAN_ATTEMPTS);*/
        if (resultCode == Activity.RESULT_OK) {
            NetswipeCardInformation cardInformation = data
                    .getParcelableExtra(NetswipeSDK.EXTRA_CARD_INFORMATION);

            //TODO card type
            //CreditCardType creditCardType = cardInformation.getCardType();

            JSONObject cardInfo = new JSONObject();
            try {
                cardInfo.put("cardNumber", getStringValue(cardInformation.getCardNumber(), true));
                cardInfo.put("expiryMonth", getStringValue(cardInformation.getExpiryDateMonth(), false));
                cardInfo.put("expiryYear", getStringValue(cardInformation.getExpiryDateYear(), false));
                cardInfo.put("cvv", getStringValue(cardInformation.getCvvCode(), false));
                cardInfo.put("cardHolderName", getStringValue(cardInformation.getCardHolderName(), false));
                cardInfo.put("sortCode", getStringValue(cardInformation.getSortCode(), false));
                cardInfo.put("accountNumber", getStringValue(cardInformation.getAccountNumber(), false));
                cardInfo.put("cardNumberManuallyEntered", cardInformation.isCardNumberManuallyEntered());

                //TODO custom fields
                //String zipCode = cardInformation.getCustomField("zip_code");

                callbackContext.success(cardInfo);

            } catch (JSONException e) {
                Log.e(LogTag, "Error creating return parameters for success callback.", e);
            } finally {
                cardInformation.clear();
                cardInfo.remove("cardNumber");
                cardInfo.remove("expiryMonth");
                cardInfo.remove("expiryYear");
                cardInfo.remove("cvv");
                cardInfo.remove("cardHolderName");
                cardInfo.remove("sortCode");
                cardInfo.remove("accountNumber");
                cardInfo.remove("cardNumberManuallyEntered");
                cardInfo = null;/*from  w w  w .j ava  2s  . c  o  m*/
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            try {
                int errorCode = data.getIntExtra(NetswipeSDK.EXTRA_ERROR_CODE, 0);
                String errorMessage = data.getStringExtra(NetswipeSDK.EXTRA_ERROR_MESSAGE);

                JSONObject cardInfo = new JSONObject();
                cardInfo.put("code", errorCode);
                cardInfo.put("message", errorMessage);

                callbackContext.error(cardInfo);
            } catch (JSONException e) {
                Log.e(LogTag, "Error creating return parameters for error callback.", e);
            }
        }
    }
}

From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java

private void readVideoPreferences(SharedPreferences prefs) {
    Intent intent = ApplicationScreen.instance.getIntent();
    // Set video duration limit. The limit is read from the preference,
    // unless it is specified in the intent.
    if (intent.hasExtra(MediaStore.EXTRA_DURATION_LIMIT)) {
        int seconds = intent.getIntExtra(MediaStore.EXTRA_DURATION_LIMIT, 0);
        mMaxVideoDurationInMs = 1000 * seconds;
    } else//from ww w  .  jav a 2 s  .co m
        mMaxVideoDurationInMs = 0;
}

From source file:eu.faircode.netguard.ServiceSinkhole.java

private void set(Intent intent) {
    // Get arguments
    int uid = intent.getIntExtra(EXTRA_UID, 0);
    String network = intent.getStringExtra(EXTRA_NETWORK);
    String pkg = intent.getStringExtra(EXTRA_PACKAGE);
    boolean blocked = intent.getBooleanExtra(EXTRA_BLOCKED, false);
    Log.i(TAG, "Set " + pkg + " " + network + "=" + blocked);

    // Get defaults
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(ServiceSinkhole.this);
    boolean default_wifi = settings.getBoolean("whitelist_wifi", true);
    boolean default_other = settings.getBoolean("whitelist_other", true);

    // Update setting
    SharedPreferences prefs = getSharedPreferences(network, Context.MODE_PRIVATE);
    if (blocked == ("wifi".equals(network) ? default_wifi : default_other))
        prefs.edit().remove(pkg).apply();
    else/*  w ww.jav  a2  s .  co  m*/
        prefs.edit().putBoolean(pkg, blocked).apply();

    // Apply rules
    ServiceSinkhole.reload("notification", ServiceSinkhole.this);

    // Update notification
    notifyNewApplication(uid);

    // Update UI
    Intent ruleset = new Intent(ActivityMain.ACTION_RULES_CHANGED);
    LocalBroadcastManager.getInstance(ServiceSinkhole.this).sendBroadcast(ruleset);
}

From source file:cn.yunluosoft.tonglou.activity.ChatActivity.java

/**
 * onActivityResult/* w ww . j av  a  2  s.  c o m*/
 */
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == 8226 && resultCode == RESULT_OK) {
        String s = data.getStringExtra("name");
        if (!ToosUtils.isStringEmpty(s)) {

            messageInfo.receiverNickName = s;
            toChatUsername = messageInfo.receiverImUserName;
            // toChatUsername = getIntent().getStringExtra("userId");
            ((TextView) findViewById(R.id.title_title)).setText(messageInfo.receiverNickName);
        }
    }
    if (resultCode == RESULT_CODE_EXIT_GROUP) {
        setResult(RESULT_OK);
        finish();
        return;
    }
    if (requestCode == REQUEST_CODE_CONTEXT_MENU) {
        switch (resultCode) {
        case RESULT_CODE_COPY: // ??
            EMMessage copyMsg = ((EMMessage) adapter.getItem(data.getIntExtra("position", -1)));
            // clipboard.setText(SmileUtils.getSmiledText(ChatActivity.this,
            // ((TextMessageBody) copyMsg.getBody()).getMessage()));
            clipboard.setText(((TextMessageBody) copyMsg.getBody()).getMessage());
            break;
        case RESULT_CODE_DELETE: // ?
            EMMessage deleteMsg = (EMMessage) adapter.getItem(data.getIntExtra("position", -1));
            conversation.removeMessage(deleteMsg.getMsgId());
            adapter.refreshSeekTo(data.getIntExtra("position", adapter.getCount()) - 1);
            break;

        // case RESULT_CODE_FORWARD: // ??
        // EMMessage forwardMsg = (EMMessage) adapter.getItem(data
        // .getIntExtra("position", 0));
        // Intent intent = new Intent(this, ForwardMessageActivity.class);
        // intent.putExtra("forward_msg_id", forwardMsg.getMsgId());
        // startActivity(intent);
        //
        // break;

        default:
            break;
        }
    }
    if (resultCode == RESULT_OK) { // ?
        if (requestCode == REQUEST_CODE_EMPTY_HISTORY) {
            // ?
            EMChatManager.getInstance().clearConversation(toChatUsername);
            adapter.refresh();
        } else if (requestCode == REQUEST_CODE_CAMERA) { // ??
            if (cameraFile != null && cameraFile.exists())
                sendPicture(cameraFile.getAbsolutePath());
        } else if (requestCode == REQUEST_CODE_SELECT_VIDEO) { // ??

            int duration = data.getIntExtra("dur", 0);
            String videoPath = data.getStringExtra("path");
            File file = new File(PathUtil.getInstance().getImagePath(), "thvideo" + System.currentTimeMillis());
            Bitmap bitmap = null;
            FileOutputStream fos = null;
            try {
                if (!file.getParentFile().exists()) {
                    file.getParentFile().mkdirs();
                }
                bitmap = ThumbnailUtils.createVideoThumbnail(videoPath, 3);
                if (bitmap == null) {
                    EMLog.d("chatactivity", "problem load video thumbnail bitmap,use default icon");
                    bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.app_panel_video_icon);
                }
                fos = new FileOutputStream(file);

                bitmap.compress(CompressFormat.JPEG, 100, fos);

            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (fos != null) {
                    try {
                        fos.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    fos = null;
                }
                if (bitmap != null) {
                    bitmap.recycle();
                    bitmap = null;
                }

            }
            sendVideo(videoPath, file.getAbsolutePath(), duration / 1000);

        } else if (requestCode == REQUEST_CODE_LOCAL) { // ??
            loading();
            // if (data != null) {
            // Uri selectedImage = data.getData();
            // if (selectedImage != null) {
            // sendPicByUri(selectedImage);
            // }
            // }
        } else if (requestCode == REQUEST_CODE_SELECT_FILE) { // ??
            if (data != null) {
                Uri uri = data.getData();
                if (uri != null) {
                    sendFile(uri);
                }
            }

        } else if (requestCode == REQUEST_CODE_MAP) { // 
            double latitude = data.getDoubleExtra("latitude", 0);
            double longitude = data.getDoubleExtra("longitude", 0);
            String locationAddress = data.getStringExtra("address");
            if (locationAddress != null && !locationAddress.equals("")) {
                toggleMore(more);
                sendLocationMsg(latitude, longitude, "", locationAddress);
            } else {
                String st = getResources().getString(R.string.unable_to_get_loaction);
                Toast.makeText(this, st, Toast.LENGTH_SHORT).show();
            }
            // ???
        } else if (requestCode == REQUEST_CODE_TEXT || requestCode == REQUEST_CODE_VOICE
                || requestCode == REQUEST_CODE_PICTURE || requestCode == REQUEST_CODE_LOCATION
                || requestCode == REQUEST_CODE_VIDEO || requestCode == REQUEST_CODE_FILE) {
            resendMessage();
        } else if (requestCode == REQUEST_CODE_COPY_AND_PASTE) {
            // 
            if (!TextUtils.isEmpty(clipboard.getText())) {
                String pasteText = clipboard.getText().toString();
                if (pasteText.startsWith(COPY_IMAGE)) {
                    // ??path
                    sendPicture(pasteText.replace(COPY_IMAGE, ""));
                }

            }
        } else if (requestCode == REQUEST_CODE_ADD_TO_BLACKLIST) { // ???
            EMMessage deleteMsg = (EMMessage) adapter.getItem(data.getIntExtra("position", -1));
            addUserToBlacklist(deleteMsg.getFrom());
        } else if (conversation.getMsgCount() > 0) {
            adapter.refresh();
            setResult(RESULT_OK);
        } else if (requestCode == REQUEST_CODE_GROUP_DETAIL) {
            adapter.refresh();
        }
    }
}

From source file:com.android.dragonkeyboardfirmwareupdater.KeyboardFirmwareUpdateService.java

/**
 * Handles intents ACTION_CONNECTION_STATE_CHANGED, ACTION_STATE_CHANGED,
 * ACTION_BOND_STATE_CHANGED, ACTION_KEYBOARD_UPDATE_CONFIRMED.
 * <p/>//from   w  w w .j  av  a  2 s .  co m
 * [ACTION_STATE_CHANGED]
 * This action is used to keep track of ON/OFF state change on the system Bluetooth adapter.
 * The
 * purpose is to synchronize the local Bluetooth connectivity with system Bluetooth state.
 * <p/>
 * [ACTION_CONNECTION_STATE_CHANGED]
 * This action is used to keep track of the connection change on the target device. The purpose
 * is to synchronize the connection cycles of the local GATT connection and the system
 * Bluetooth
 * connection.
 * <p/>
 * [ACTION_BOND_STATE_CHANGED]
 * This action is used to keep track of the bond state change on the target device. The purpose
 * is to the connection cycles of the local GATT connection and the system Bluetooth
 * connection.
 * <p/>
 * [ACTION_KEYBOARD_UPDATE_CONFIRMED]
 * This action is used to receive the update confirmation from the user. The purpose is to
 * trigger DFU process.
 */
private void onHandleIntent(Context context, Intent intent) {
    final String action = intent.getAction();
    Log.d(TAG, "onHandleIntent: Received action: " + action);

    if (BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED.equals(action)) {

        if (!isBluetoothEnabled()) {
            Log.w(TAG, "onHandleIntent: Bluetooth connectivity not enabled");
            return;
        }

        // Match the connected device with the default keyboard name.
        Bundle extras = intent.getExtras();
        if (extras == null)
            return;
        final BluetoothDevice device = extras.getParcelable(BluetoothDevice.EXTRA_DEVICE);
        final int deviceConnectionState = extras.getInt(BluetoothAdapter.EXTRA_CONNECTION_STATE);

        Log.d(TAG, "onHandleIntent: " + device.getName() + " [" + device.getAddress() + "] change to state: "
                + deviceConnectionState);

        // Match the name of the target keyboard.
        if (!isTargetKeyboard(device))
            return;

        if (deviceConnectionState == BluetoothAdapter.STATE_CONNECTED) {
            // Prevent the second keyboard from using the service.
            if (isUpdateServiceInUse())
                return;

            obtainKeyboardInfo(device.getName(), device.getAddress());

            if (mDfuStatus != DFU_STATE_INFO_READY) {
                Log.w(TAG, "onHandleIntent: DFU preparation failed");
                changeDfuStatus(DFU_STATE_OBTAIN_INFO_ERROR);
                return;
            }

            showUpdateNotification();
        } else if (deviceConnectionState == BluetoothAdapter.STATE_DISCONNECTING) {
            handleGattDisconnection();
        }

    } else if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {
        final int adapterState = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
        if (adapterState == BluetoothAdapter.STATE_ON) {
            if (!isBluetoothEnabled())
                enableBluetoothConnectivity();
        } else if (adapterState == BluetoothAdapter.STATE_TURNING_OFF) {
            // Terminate update process and disable Bluetooth connectivity.
            disableBluetoothConnectivity();

            // Since BluetoothAdapter has been disabled, the callback of disconnection would not
            // be called. Therefore a separate clean-up of GATT connection is need.
            cleanUpGattConnection();
        }

    } else if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
        Bundle extras = intent.getExtras();
        if (extras == null)
            return;
        final BluetoothDevice device = extras.getParcelable(BluetoothDevice.EXTRA_DEVICE);
        final int deviceBondState = extras.getInt(BluetoothDevice.EXTRA_BOND_STATE);

        Log.d(TAG, "onHandleIntent: state change on device " + device.getName() + " [" + device.getAddress()
                + "], bond state: " + deviceBondState);

        if (!isTargetKeyboard(device))
            return;

        if (deviceBondState == BluetoothDevice.BOND_NONE) {
            handleGattDisconnection();
        }

    } else if (ACTION_KEYBOARD_UPDATE_CONFIRMED.equals(action)) {
        dismissUpdateNotification();

        if (mDfuStatus != DFU_STATE_INFO_READY || mDfuStatus == DFU_STATE_UPDATING) {
            Log.w(TAG, "onHandleIntent: DFP preparation not ready or DFU is in progress. ");
            changeDfuStatus(DFU_STATE_UPDATE_ABORTED);
            return;
        }

        String keyboardName = intent.getStringExtra(EXTRA_KEYBOARD_NAME);
        String keyboardAddress = intent.getStringExtra(EXTRA_KEYBOARD_ADDRESS);
        if (!mKeyboardName.equals(keyboardName) || !mKeyboardAddress.equals(keyboardAddress)) {
            Log.w(TAG, "onHandleIntent: No DFU service associated with " + keyboardName + " [" + keyboardAddress
                    + "]");
            return;
        }

        Log.d(TAG, "onHandleIntent: Start update process on " + keyboardName + " [" + keyboardAddress + "]");
        changeDfuStatus(DFU_STATE_SWITCHING_TO_DFU_MODE);

    } else if (ACTION_KEYBOARD_UPDATE_POSTPONED.equals(action)) {
        dismissUpdateNotification();
        // TODO(mcchou): Update the preference when the Settings keyboard entry is available.
    }
}

From source file:com.android.launcher3.widget.DigitalAppWidgetProvider.java

@Override
public void onReceive(Context context, Intent intent) {
    mComtext = context;//  w  w w . ja v  a2  s  .  c  o  m
    String action = intent.getAction();
    Log.i("sai", "onReceive: " + action);

    super.onReceive(context, intent);

    if (ACTION_ON_QUARTER_HOUR.equals(action) || Intent.ACTION_DATE_CHANGED.equals(action)
            || Intent.ACTION_TIMEZONE_CHANGED.equals(action) || Intent.ACTION_TIME_CHANGED.equals(action)
            || Intent.ACTION_LOCALE_CHANGED.equals(action)) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        if (appWidgetManager != null) {
            int[] appWidgetIds = appWidgetManager.getAppWidgetIds(getComponentName(context));
            for (int appWidgetId : appWidgetIds) {
                RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.digital_appwidget);
                float ratio = WidgetUtils.getScaleRatio(context, null, appWidgetId);
                // SPRD for bug421127 add am/pm for widget
                WidgetUtils.setTimeFormat(widget,
                        (int) context.getResources().getDimension(R.dimen.widget_label_font_size),
                        R.id.the_clock);
                WidgetUtils.setClockSize(context, widget, ratio);
                //refreshAlarm(context, widget);
                appWidgetManager.partiallyUpdateAppWidget(appWidgetId, widget);
            }
        }
        if (!ACTION_ON_QUARTER_HOUR.equals(action)) {
            cancelAlarmOnQuarterHour(context);
        }
        startAlarmOnQuarterHour(context);
    }
    // cg sai.pan begin
    else if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        if (appWidgetManager != null) {
            int[] appWidgetIds = appWidgetManager.getAppWidgetIds(getComponentName(context));
            for (int appWidgetId : appWidgetIds) {
                RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.digital_appwidget);
                refreshBtStatus(context, widget);
                appWidgetManager.partiallyUpdateAppWidget(appWidgetId, widget);
            }
        }
    } else if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
        int wifiStatus = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);
        Log.e("sai", "wifiStatus" + wifiStatus);
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        if (appWidgetManager != null) {
            int[] appWidgetIds = appWidgetManager.getAppWidgetIds(getComponentName(context));
            for (int appWidgetId : appWidgetIds) {
                RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.digital_appwidget);
                if (WifiManager.WIFI_STATE_ENABLED == wifiStatus
                        || WifiManager.WIFI_STATE_ENABLING == wifiStatus) {
                    widget.setImageViewResource(R.id.wifi, R.drawable.status_wifi_on);
                } else {
                    widget.setImageViewResource(R.id.wifi, R.drawable.status_wifi_off);
                }
                appWidgetManager.partiallyUpdateAppWidget(appWidgetId, widget);
            }
        }
    } else if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        if (appWidgetManager != null) {
            int[] appWidgetIds = appWidgetManager.getAppWidgetIds(getComponentName(context));
            for (int appWidgetId : appWidgetIds) {
                RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.digital_appwidget);
                refreshWifiStatus(context, widget);
            }
        }
    } else if ("android.net.conn.CONNECTIVITY_CHANGE".equals(action)) {
        if (isNetworkConnected(context)) {
            Log.e("sai", "isNetworkConnected true");
            requestLocation(context);
        } else {
            Log.e("sai", "isNetworkConnected false");
        }
    }
}

From source file:de.vanita5.twittnuker.util.Utils.java

public static boolean isBatteryOkay(final Context context) {
    if (context == null)
        return false;
    final Context app = context.getApplicationContext();
    final IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    final Intent intent = app.registerReceiver(null, filter);
    if (intent == null)
        return false;
    final boolean plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) != 0;
    final float level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
    final float scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, 100);
    return plugged || level / scale > 0.15f;
}

From source file:com.hypodiabetic.happ.MainActivity.java

@Override
protected void onResume() {
    super.onResume();

    //xdrip start
    extendedGraphBuilder = new ExtendedGraphBuilder(getApplicationContext());

    _broadcastReceiver = new BroadcastReceiver() {
        @Override/*from w  w  w .  j a  va  2s .  c o  m*/
        public void onReceive(Context ctx, Intent intent) {
            if (intent.getAction().compareTo(Intent.ACTION_TIME_TICK) == 0) {
                setupBGCharts();
                displayCurrentInfo();
                holdViewport.set(0, 0, 0, 0);
            }
        }
    };
    newDataReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context ctx, Intent intent) {
            setupBGCharts();
            displayCurrentInfo();
            holdViewport.set(0, 0, 0, 0);
        }
    };
    registerReceiver(_broadcastReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));
    registerReceiver(newDataReceiver, new IntentFilter(Intents.ACTION_NEW_BG));
    setupBGCharts();
    displayCurrentInfo();
    holdViewport.set(0, 0, 0, 0);
    //xdrip end

    //listens out for new Stats
    newStatsReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
            Stats stat = gson.fromJson(intent.getStringExtra("stat"), Stats.class);

            updateStats(stat);
            displayCurrentInfo();
        }
    };
    registerReceiver(newStatsReceiver, new IntentFilter("ACTION_UPDATE_STATS"));
    updateStats(null);

    //listens out for openAPS updates
    newAPSUpdate = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
            APSResult apsResult = gson.fromJson(intent.getStringExtra("APSResult"), APSResult.class);

            updateOpenAPSDetails(apsResult);
            setupBGCharts();
            displayCurrentInfo();
        }
    };
    registerReceiver(newAPSUpdate, new IntentFilter("APS_UPDATE"));

    //listens out for app notifications
    appNotification = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            int snackbar_length;
            snackbar_length = intent.getIntExtra("snackbar_length", Snackbar.LENGTH_INDEFINITE);
            final String alertDialogText = intent.getStringExtra("alertDialogText");
            String snackBarMsg = intent.getStringExtra("snackBarMsg");

            Snackbar snackbar = Snackbar
                    .make(MainActivity.activity.findViewById(R.id.mainActivity), snackBarMsg, snackbar_length)
                    .setAction("DETAILS", new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.activity);
                            builder.setMessage(alertDialogText);
                            builder.setPositiveButton("OK", null);
                            builder.show();
                        }
                    });
            snackbar.show();

        }
    };
    registerReceiver(appNotification, new IntentFilter("NEW_APP_NOTIFICATION"));

}

From source file:com.bookkos.bircle.CaptureActivity.java

@Override
protected void onResume() {
    super.onResume();

    // cameraManager?????????????(onCreate????????????)
    cameraManager = new CameraManager(getApplication());

    viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view);
    viewfinderView.setCameraManager(cameraManager);

    //      resultView = findViewById(R.id.result_view);

    handler = null;//from  www.  j  av  a  2 s .  com
    lastResult = null;
    registFlag = 0;
    resetStatusView();

    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    if (hasSurface) {
        initCamera(surfaceHolder);
    } else {
        surfaceHolder.addCallback(this);
    }

    bircleBeepManager.updatePrefs();
    ambientLightManager.start(cameraManager);

    inactivityTimer.onResume();

    Intent intent = getIntent();

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    copyToClipboard = prefs.getBoolean(PreferencesActivity.KEY_COPY_TO_CLIPBOARD, true)
            && (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true));

    source = IntentSource.NONE;
    decodeFormats = null;
    characterSet = null;

    if (intent != null) {

        String action = intent.getAction();
        String dataString = intent.getDataString();

        if (Intents.Scan.ACTION.equals(action)) {

            source = IntentSource.NATIVE_APP_INTENT;
            decodeFormats = DecodeFormatManager.parseDecodeFormats(intent);
            decodeHints = DecodeHintManager.parseDecodeHints(intent);

            if (intent.hasExtra(Intents.Scan.WIDTH) && intent.hasExtra(Intents.Scan.HEIGHT)) {
                int width = intent.getIntExtra(Intents.Scan.WIDTH, 0);
                int height = intent.getIntExtra(Intents.Scan.HEIGHT, 0);
                if (width > 0 && height > 0) {
                    cameraManager.setManualFramingRect(width, height);
                }
            }

            String customPromptMessage = intent.getStringExtra(Intents.Scan.PROMPT_MESSAGE);
            if (customPromptMessage != null) {
            }

        } else if (dataString != null && dataString.contains("http://www.google")
                && dataString.contains("/m/products/scan")) {

            source = IntentSource.PRODUCT_SEARCH_LINK;
            sourceUrl = dataString;
            decodeFormats = DecodeFormatManager.PRODUCT_FORMATS;

        } else if (isZXingURL(dataString)) {

            source = IntentSource.ZXING_LINK;
            sourceUrl = dataString;
            Uri inputUri = Uri.parse(dataString);
            decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri);
            decodeHints = DecodeHintManager.parseDecodeHints(inputUri);
        }

        characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET);

    }
}