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:org.ubicompforall.cityexplorer.gui.PoiDetailsActivity.java

/***
 * onCreate: StartUp Method/* ww w .  ja  v  a 2 s.com*/
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.details_poi_layout);

    Intent myIntent = getIntent();
    if (myIntent.getParcelableExtra("poi") != null) {
        poi = (Poi) myIntent.getParcelableExtra("poi");
    } else {
        debug(0, "No poi supplied.. exit activity");
        this.finish();
    }

    if (myIntent.getParcelableExtra("trip") != null) {
        prevPoi = (ImageButton) findViewById(R.id.previousPoiButton); // TODO: POI MUST BE UPDATED WHEN THE ARROW ARE USED
        nextPoi = (ImageButton) findViewById(R.id.nextPoiButton);
        prevPoi.setVisibility(0);
        nextPoi.setVisibility(0);
        prevPoi.setOnClickListener(this);
        nextPoi.setOnClickListener(this);
        trip = myIntent.getParcelableExtra("trip");
        pois = new ArrayList<Poi>();
        for (Poi p : trip.getPois()) {
            pois.add(p);
        }
        poiNumber = myIntent.getIntExtra("poiNumber", 0);
        if (poiNumber == 0) {
            prevPoi.setEnabled(false);
            if (pois.size() == 1) {
                nextPoi.setEnabled(false);
            }
        } else if (poiNumber == pois.size() - 1) {
            nextPoi.setEnabled(false);
        }

    } else {
        debug(0, "No trip supplied..");
    }

    title = (TextView) findViewById(R.id.label);
    address = (TextView) findViewById(R.id.address);
    description = (TextView) findViewById(R.id.description);
    category = (TextView) findViewById(R.id.category);
    telephone = (TextView) findViewById(R.id.telephone);
    openingHours = (TextView) findViewById(R.id.openingHours);
    webPage = (TextView) findViewById(R.id.webPage);
    poiImage = (ImageView) findViewById(R.id.imageContainer);

    showPoiDetails(poi);
}

From source file:com.dwdesign.tweetings.fragment.StatusFragment.java

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) {
    if (intent == null || mStatus == null)
        return;//from  ww w .  j  a v a2 s.co m
    switch (requestCode) {
    case REQUEST_SET_COLOR: {
        if (resultCode == Activity.RESULT_OK)
            if (intent != null && intent.getExtras() != null) {
                final int color = intent.getIntExtra(Accounts.USER_COLOR, Color.TRANSPARENT);
                setUserColor(getActivity(), mStatus.user_id, color);
                updateUserColor();
            }
        break;
    }
    }

}

From source file:fr.bmartel.android.fadecandy.service.FadecandyService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    //this is the activity which will be opened when user click on notification
    Intent testIntent = new Intent();
    if (intent != null && intent.hasExtra(Constants.SERVICE_EXTRA_ACTIVITY)) {
        testIntent.setComponent(/*  w ww.ja va 2  s .  co  m*/
                ComponentName.unflattenFromString(intent.getStringExtra(Constants.SERVICE_EXTRA_ACTIVITY)));
    }

    ServiceType serviceTypeOverride;

    if (intent != null && intent.hasExtra(Constants.SERVICE_EXTRA_SERVICE_TYPE)) {
        serviceTypeOverride = ServiceType.getServiceType(intent.getIntExtra(
                Constants.SERVICE_EXTRA_SERVICE_TYPE, ServiceType.NON_PERSISTENT_SERVICE.ordinal()));
    } else {
        serviceTypeOverride = mServiceType;
    }

    switch (serviceTypeOverride) {
    case NON_PERSISTENT_SERVICE:
        Log.v(TAG, "starting NON_PERSISTENT_SERVICE...");
        return START_NOT_STICKY;
    case PERSISTENT_SERVICE:
        startForeground(4242, NotificationHelper.createNotification(this, null, testIntent));
        Log.v(TAG, "starting PERSISTENT_SERVICE...");
        return START_STICKY;
    }

    return START_NOT_STICKY;
}

From source file:com.android.music.MusicBrowserActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    /// M: Get the start activity tab index from intent which set by start activity,
    // so that we can return
    /// result to right activity.

    if (mPermissionReqProcessed == true) {
        int startActivityTab = mCurrentTab;
        if (data != null) {
            startActivityTab = data.getIntExtra(MusicUtils.START_ACTIVITY_TAB_ID, mCurrentTab);
        }/* ww w  . j  a  va2s . co  m*/
        MusicLogUtils.d(TAG, "onActivityResult: startActivityTab = " + startActivityTab);
        Activity startActivity = mActivityManager.getActivity(getStringId(startActivityTab));
        if (startActivity == null) {
            return;
        }
        switch (startActivityTab) {
        case ARTIST_INDEX:
            ((ArtistAlbumBrowserActivity) startActivity).onActivityResult(requestCode, resultCode, data);
            break;

        case ALBUM_INDEX:
            ((AlbumBrowserActivity) startActivity).onActivityResult(requestCode, resultCode, data);
            break;

        case SONG_INDEX:
            ((TrackBrowserActivity) startActivity).onActivityResult(requestCode, resultCode, data);
            break;

        case PLAYLIST_INDEX:
            ((PlaylistBrowserActivity) startActivity).onActivityResult(requestCode, resultCode, data);
            break;

        default:
            MusicLogUtils.d(TAG, "default");
            break;
        }
    }
}

From source file:com.intel.xdk.device.Device.java

private void registerBatteryChangeReceiver() {

    if (batteryChangeReceiver == null) {

        batteryChangeReceiver = new BroadcastReceiver() {

            @Override//from  w  w  w .  j  a v  a  2 s  .co  m
            public void onReceive(Context context, Intent intent) {
                int batteryStatus = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
                boolean isCharging = batteryStatus == BatteryManager.BATTERY_STATUS_CHARGING
                        || batteryStatus == BatteryManager.BATTERY_STATUS_FULL;

                if (isCharging) {
                    if (wl == null) {
                        aquireWakeLock();
                    }
                } else {
                    if (wl != null) {
                        wl.release();
                        wl = null;
                    }
                }
            }

        };
    }

    activity.registerReceiver(batteryChangeReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
}

From source file:com.xgf.inspection.qrcode.google.zxing.client.CaptureActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if (resultCode == RESULT_OK) {
        if (requestCode == HISTORY_REQUEST_CODE) {
            int itemNumber = intent.getIntExtra(Intents.History.ITEM_NUMBER, -1);
            if (itemNumber >= 0) {
                HistoryItem historyItem = historyManager.buildHistoryItem(itemNumber);
                decodeOrStoreSavedBitmap(null, historyItem.getResult());
            }/*  w ww . j  a  v  a 2s. c o m*/
        }
    }
}

From source file:com.sharky.BillingService.java

public void handleCommand(Intent intent, int startId) {
    String action = intent.getAction();
    if (Consts.ACTION_CONFIRM_NOTIFICATION.equals(action)) {
        String[] notifyIds = intent.getStringArrayExtra(Consts.NOTIFICATION_ID);
        confirmNotifications(startId, notifyIds);
    } else if (Consts.ACTION_GET_PURCHASE_INFORMATION.equals(action)) {
        String notifyId = intent.getStringExtra(Consts.NOTIFICATION_ID);
        getPurchaseInformation(startId, new String[] { notifyId });
    } else if (Consts.ACTION_PURCHASE_STATE_CHANGED.equals(action)) {
        String signedData = intent.getStringExtra(Consts.INAPP_SIGNED_DATA);
        String signature = intent.getStringExtra(Consts.INAPP_SIGNATURE);
        purchaseStateChanged(startId, signedData, signature);
    } else if (Consts.ACTION_RESPONSE_CODE.equals(action)) {
        long requestId = intent.getLongExtra(Consts.INAPP_REQUEST_ID, -1);
        int responseCodeIndex = intent.getIntExtra(Consts.INAPP_RESPONSE_CODE,
                ResponseCode.RESULT_ERROR.ordinal());
        ResponseCode responseCode = ResponseCode.valueOf(responseCodeIndex);
        checkResponseCode(requestId, responseCode);
    }//from  w  w  w  .jav  a  2s  . com
}

From source file:com.example.zf_android.trade.ApplyDetailActivity.java

@Override
protected void onActivityResult(final int requestCode, int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode != RESULT_OK)
        return;//  w  w  w. j a v  a  2 s.c o  m
    switch (requestCode) {
    case REQUEST_CHOOSE_MERCHANT: {

        mAgentId = mMerchantId = data.getIntExtra(AGENT_ID, 0);
        mAgentName = data.getStringExtra(AGENT_NAME);
        setItemValue(mMerchantKeys[0], mAgentName);

        getAgentInfo();

        break;
    }
    case REQUEST_CHOOSE_BANK: {

        mBankName = data.getStringExtra("bank_name");
        mBankNo = data.getStringExtra("bank_no");
        setItemValue(customTag, mBankName);
        setItemValue(mBankKeys[0], mBankName);

        //FIXME no 
        //                setItemValue(mBankKeys[1], mBankNo);

        break;
    }
    case REQUEST_CHOOSE_CITY: {
        mMerchantProvince = (Province) data.getSerializableExtra(SELECTED_PROVINCE);
        mMerchantCity = (City) data.getSerializableExtra(SELECTED_CITY);
        mCityId = mMerchantCity.getId();
        setItemValue(mMerchantKeys[8], mMerchantCity.getName());
        break;
    }
    case REQUEST_CHOOSE_CHANNEL: {
        mChannelId = data.getIntExtra("channelId", 0);
        mBillingId = data.getIntExtra("billId", 0);
        String channelName = data.getStringExtra("channelName");
        String billName = data.getStringExtra("billName");

        setItemValue(getString(R.string.apply_detail_channel), channelName + " " + billName);
        break;
    }
    case REQUEST_UPLOAD_IMAGE:
    case REQUEST_TAKE_PHOTO: {

        final Handler handler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                if (msg.what == 1) {
                    //                     CommonUtil.toastShort(ApplyDetailActivity.this, (String) msg.obj);
                    if (null != uploadingTextView) {
                        final String url = (String) msg.obj;
                        LinearLayout item = (LinearLayout) uploadingTextView.getParent().getParent();

                        updateCustomerDetails(item.getTag(), url);
                        uploadingTextView.setVisibility(View.GONE);

                        ImageView iv_view = (ImageView) item.findViewById(R.id.apply_detail_view);
                        iv_view.setVisibility(View.VISIBLE);
                        iv_view.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent i = new Intent(ApplyDetailActivity.this, ImageViewer.class);
                                i.putExtra("url", url);
                                i.putExtra("justviewer", true);
                                startActivity(i);
                            }
                        });
                    }
                } else {
                    CommonUtil.toastShort(ApplyDetailActivity.this, getString(R.string.toast_upload_failed));
                    if (null != uploadingTextView) {
                        uploadingTextView.setText(getString(R.string.apply_upload_again));
                        uploadingTextView.setClickable(true);
                    }
                }

            }
        };
        if (null != uploadingTextView) {
            uploadingTextView.setText(getString(R.string.apply_uploading));
            uploadingTextView.setClickable(false);
        }
        new Thread() {
            @Override
            public void run() {
                String realPath = "";
                if (requestCode == REQUEST_TAKE_PHOTO) {
                    realPath = photoPath;
                } else {
                    Uri uri = data.getData();
                    if (uri != null) {
                        realPath = getRealPathFromURI(uri);
                    }
                }
                if (TextUtils.isEmpty(realPath)) {
                    handler.sendEmptyMessage(0);
                    return;
                }
                CommonUtil.uploadFile(realPath, "img", new CommonUtil.OnUploadListener() {
                    @Override
                    public void onSuccess(String result) {
                        try {
                            JSONObject jo = new JSONObject(result);
                            String url = jo.getString("result");
                            Message msg = new Message();
                            msg.what = 1;
                            msg.obj = url;
                            handler.sendMessage(msg);
                        } catch (JSONException e) {
                            handler.sendEmptyMessage(0);
                        }
                    }

                    @Override
                    public void onFailed(String message) {
                        handler.sendEmptyMessage(0);
                    }
                });
            }
        }.start();
        break;
    }
    }
}

From source file:radu.pidroid.Controller.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.controller);

    ActionBar actionBar = getActionBar();
    actionBar.hide();/* w  ww .j av  a  2  s.  c  om*/

    speechButton = (ImageView) findViewById(R.id.speechButton);
    speechButton.setOnClickListener(new ImageView.OnClickListener() {
        public void onClick(View view) {
            startVoiceRecognition();
        } // onClick
    });

    touchControlsLayout = (RelativeLayout) findViewById(R.id.TouchControlsLayout);
    forwardsPowerImageView = (ImageView) findViewById(R.id.forwardsPowerImageView);
    forwardsPowerImageView.setOnTouchListener(this);
    backwardsPowerImageView = (ImageView) findViewById(R.id.backwardsPowerImageView);
    backwardsPowerImageView.setOnTouchListener(this);

    forwardsPowerProgressBar = (ProgressBar) findViewById(R.id.forwardsPowerProgressBar);
    backwardsPowerProgressBar = (ProgressBar) findViewById(R.id.backwardsPowerProgressBar);

    sliderControlsLayout = (RelativeLayout) findViewById(R.id.SliderControlsLayout);
    forwardsPowerSeekBar = (SeekBar) findViewById(R.id.forwardsPowerSeekBar);
    forwardsPowerSeekBar.setOnSeekBarChangeListener(this);
    backwardsPowerSeekBar = (SeekBar) findViewById(R.id.backwardsPowerSeekBar);
    backwardsPowerSeekBar.setOnSeekBarChangeListener(this);

    joystickControlsLayout = (RelativeLayout) findViewById(R.id.JoystickControlsLayout);
    largeCameraJoystickView = (JoystickView) findViewById(R.id.largeCameraJoystickView);
    largeCameraJoystickView.setMoveListener(this);
    directionJoystickView = (JoystickView) findViewById(R.id.directionJoystickView);
    directionJoystickView.setMoveListener(this);

    videoFeedMjpegView = (MjpegView) findViewById(R.id.videoFeedSurfaceView);
    hudImageView = (ImageView) findViewById(R.id.hudImageView);
    levelIndicatorImageView = (ImageView) findViewById(R.id.levelIndicatorImageView);

    mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    mGeomagnetic = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);

    smallCameraJoystickView = (JoystickView) findViewById(R.id.cameraJoystickView);
    smallCameraJoystickView.setMoveListener(this);
    smallCameraJoystickView.setTag("smallCamera");

    spinControlOn = false;
    toggleSpinImageView = (ImageView) findViewById(R.id.toggleSpinImageView);
    toggleSpinImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            // if spinControl is ON then tiltControls are OFF and vice versa
            spinControlOn = !spinControlOn;
            tiltControlsOn = !tiltControlsOn;

            if (spinControlOn)
                toggleSpinImageView.setImageResource(R.drawable.spin_button_down);
            else
                toggleSpinImageView.setImageResource(R.drawable.spin_button_up);

            // Let PiDroid know whether to spin
            mMessenger.toggleSpin(spinControlOn);
        } // onClick
    });

    // Get the message from the intent
    Intent intent = getIntent();
    serverIP = intent.getStringExtra(Main.EXTRA_SERVERIP);
    serverPort = intent.getIntExtra(Main.EXTRA_SERVERPORT, 8090);

    mMessenger = new Messenger(this, serverIP, serverPort);
    mRecogniser = new CommandRecogniser(this, mMessenger, videoFeedMjpegView);

    if (Main.detailsCheckBox.isChecked())
        loadPreferences();
    else
        clearPreferences();

    setupNavigationDrawer();
    setupVideoFeed();

    if (tutorialsOn)
        new ControllerTutorial(this).start();
}

From source file:com.trimble.mcs.cordova.plugin.TrmbMcsRfid.java

public void handleRfidTagIntent(Context context, Intent intent) {
    CallbackContext cb = mScanTagCallback;
    if (cb == null)
        return;//  w  ww  . jav  a 2s.c  o  m

    String action = intent.getAction();

    if (action.equals(RfidConstants.ACTION_RFID_TAG_SCANNED)) {
        // Extract tag data from intent
        String tagID = intent.getStringExtra(RfidConstants.RFID_FIELD_ID);
        String memory = intent.getStringExtra(RfidConstants.RFID_FIELD_MEMORY);
        String tagType = intent.getStringExtra(RfidConstants.RFID_FIELD_TAG_TYPE);
        int rssi = intent.getIntExtra(RfidConstants.RFID_FIELD_RSSI, 0);
        int readCount = intent.getIntExtra(RfidConstants.RFID_FIELD_READ_COUNT, 0);
        long timeStamp = intent.getLongExtra(RfidConstants.RFID_FIELD_TIME_STAMP, 0);

        // Store tag data in a JSON object for transmission to javascript
        JSONObject tagInfo = new JSONObject();
        try {
            if (tagID != null)
                tagInfo.put("tagID", tagID);
            if (memory != null)
                tagInfo.put("memory", memory);
            if (tagType != null)
                tagInfo.put("tagType", tagType);
            if (rssi != 0)
                tagInfo.put("rssi", rssi);
            if (readCount != 0)
                tagInfo.put("readCount", readCount);
            if (timeStamp != 0)
                tagInfo.put("timeStamp", timeStamp);
        } catch (JSONException e) {
            Log.d(TAG, "Error populating JSON object with scan data: " + e.getMessage());
        }

        PluginResult result = new PluginResult(PluginResult.Status.OK, tagInfo);
        result.setKeepCallback(true);
        cb.sendPluginResult(result);
    }
}