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.ceino.chaperonandroid.activities.LicenseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ChaperOnApplication.get(this).inject(this);
    chaperOnConnection = new ChaperOnConnection(this);
    overridePendingTransition(R.anim.animation, R.anim.animation2);
    setContentView(R.layout.activity_licenseverify);
    ButterKnife.inject(this);
    toastHandler = new ToastHandler(this);
    Intent intent = getIntent();
    phone = intent.getStringExtra("phone");
    email = intent.getStringExtra("email");
    password = intent.getStringExtra("pwd");
    firstname = intent.getStringExtra("fname");
    username = intent.getStringExtra("uname");
    imagePath = intent.getStringExtra("imgpath");
    street = intent.getStringExtra("street");
    apartment = intent.getStringExtra("aptno");
    city = intent.getStringExtra("city");
    postal = intent.getStringExtra("postal");
    country = intent.getStringExtra("country");
    lastname = intent.getStringExtra("lname");
    description = intent.getStringExtra("desc");
    rideType = intent.getIntExtra("ridetype", 0);
    lattitude = intent.getDoubleExtra("lat", 0);
    longtitude = intent.getDoubleExtra("long", 0);

    Drawable drawable = getResources().getDrawable(R.drawable.hash);
    drawable.setBounds(0, 0, (int) (drawable.getIntrinsicWidth() * 0.4),
            (int) (drawable.getIntrinsicHeight() * 0.4));
    ScaleDrawable sd = new ScaleDrawable(drawable, 0, 1f, 1f);

    emptySeats.setCompoundDrawablePadding(15);
    emptySeats.setCompoundDrawables(sd.getDrawable(), null, null, null);

    imgBack.setOnClickListener(this);
    imgLicense.setOnClickListener(this);
    saveAllbtn.setOnClickListener(this);
}

From source file:biz.wiz.android.wallet.service.BlockchainServiceImpl.java

@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {
    if (intent != null) {
        log.info("service start command: " + intent
                + (intent.hasExtra(Intent.EXTRA_ALARM_COUNT)
                        ? " (alarm count: " + intent.getIntExtra(Intent.EXTRA_ALARM_COUNT, 0) + ")"
                        : ""));

        final String action = intent.getAction();

        if (BlockchainService.ACTION_CANCEL_COINS_RECEIVED.equals(action)) {
            notificationCount = 0;/*www.  ja va  2 s .c o m*/
            notificationAccumulatedAmount = Coin.ZERO;
            notificationAddresses.clear();

            nm.cancel(NOTIFICATION_ID_COINS_RECEIVED);
        } else if (BlockchainService.ACTION_RESET_BLOCKCHAIN.equals(action)) {
            log.info("will remove blockchain on service shutdown");

            resetBlockchainOnShutdown = true;
            stopSelf();
        } else if (BlockchainService.ACTION_BROADCAST_TRANSACTION.equals(action)) {
            final Sha256Hash hash = new Sha256Hash(
                    intent.getByteArrayExtra(BlockchainService.ACTION_BROADCAST_TRANSACTION_HASH));
            final Transaction tx = application.getWallet().getTransaction(hash);

            if (peerGroup != null) {
                log.info("broadcasting transaction " + tx.getHashAsString());
                peerGroup.broadcastTransaction(tx);
            } else {
                log.info("peergroup not available, not broadcasting transaction " + tx.getHashAsString());
            }
        }
    } else {
        log.warn("service restart, although it was started as non-sticky");
    }

    return START_NOT_STICKY;
}

From source file:net.oschina.app.v2.activity.zxing.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());
            }// ww w .  ja  va  2  s  . c o m
        }
    }
}

From source file:com.androidinspain.deskclock.timer.TimerFragment.java

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

    // We may have received a new intent while paused.
    final Intent intent = getActivity().getIntent();
    if (intent != null && intent.hasExtra(TimerService.EXTRA_TIMER_ID)) {
        // This extra is single-use; remove after honoring it.
        final int showTimerId = intent.getIntExtra(TimerService.EXTRA_TIMER_ID, -1);
        intent.removeExtra(TimerService.EXTRA_TIMER_ID);

        final Timer timer = DataModel.getDataModel().getTimer(showTimerId);
        if (timer != null) {
            // A specific timer must be shown; show the list of timers.
            final int index = DataModel.getDataModel().getTimers().indexOf(timer);
            mViewPager.setCurrentItem(index);

            animateToView(mTimersView, null, false);
        }/*from  w  w  w .  jav a  2 s .  c  om*/
    }
}

From source file:com.android.packageinstaller.PackageInstallerActivity.java

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    mPm = getPackageManager();/*from ww w.  j a  va2  s .  c o m*/
    mInstaller = mPm.getPackageInstaller();
    mUserManager = (UserManager) getSystemService(Context.USER_SERVICE);

    final Intent intent = getIntent();
    mOriginatingUid = getOriginatingUid(intent);

    final Uri packageUri;

    if (PackageInstaller.ACTION_CONFIRM_PERMISSIONS.equals(intent.getAction())) {
        final int sessionId = intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID, -1);
        final PackageInstaller.SessionInfo info = mInstaller.getSessionInfo(sessionId);
        if (info == null || !info.sealed || info.resolvedBaseCodePath == null) {
            Log.w(TAG, "Session " + mSessionId + " in funky state; ignoring");
            finish();
            return;
        }

        mSessionId = sessionId;
        packageUri = Uri.fromFile(new File(info.resolvedBaseCodePath));
        mOriginatingURI = null;
        mReferrerURI = null;
    } else {
        mSessionId = -1;
        packageUri = intent.getData();
        mOriginatingURI = intent.getParcelableExtra(Intent.EXTRA_ORIGINATING_URI);
        mReferrerURI = intent.getParcelableExtra(Intent.EXTRA_REFERRER);
    }

    // if there's nothing to do, quietly slip into the ether
    if (packageUri == null) {
        Log.w(TAG, "Unspecified source");
        setPmResult(PackageManager.INSTALL_FAILED_INVALID_URI);
        finish();
        return;
    }

    if (DeviceUtils.isWear(this)) {
        showDialogInner(DLG_NOT_SUPPORTED_ON_WEAR);
        return;
    }

    //set view
    setContentView(R.layout.install_start);
    mInstallConfirm = findViewById(R.id.install_confirm_panel);
    mInstallConfirm.setVisibility(View.INVISIBLE);
    mOk = (Button) findViewById(R.id.ok_button);
    mCancel = (Button) findViewById(R.id.cancel_button);
    mOk.setOnClickListener(this);
    mCancel.setOnClickListener(this);

    // Block the install attempt on the Unknown Sources setting if necessary.
    final boolean requestFromUnknownSource = isInstallRequestFromUnknownSource(intent);
    if (!requestFromUnknownSource) {
        processPackageUri(packageUri);
        return;
    }

    // If the admin prohibits it, or we're running in a managed profile, just show error
    // and exit. Otherwise show an option to take the user to Settings to change the setting.
    final boolean isManagedProfile = mUserManager.isManagedProfile();
    if (!isUnknownSourcesAllowedByAdmin()) {
        startActivity(new Intent(Settings.ACTION_SHOW_ADMIN_SUPPORT_DETAILS));
        clearCachedApkIfNeededAndFinish();
    } else if (!isUnknownSourcesEnabled() && isManagedProfile) {
        showDialogInner(DLG_ADMIN_RESTRICTS_UNKNOWN_SOURCES);
    } else if (!isUnknownSourcesEnabled()) {
        // Ask user to enable setting first

        showDialogInner(DLG_UNKNOWN_SOURCES);
    } else {
        processPackageUri(packageUri);
    }
}

From source file:com.kiwiteam.nomiddleman.TourPageActivity.java

/**
 * Calls the class that queries the tour information
 * @param intent/*  w w  w.  j av a 2 s.  c om*/
 */
public void initTourPage(Intent intent) {
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    ratings.clear();
    tourRatingsA.clear();
    tourSessionsA.clear();

    tourID = intent.getIntExtra("tourId", -1);

    if (tourID == -1) {
        finish();
    } else {
        query = tourID;
        new GetTourPage().execute();
    }
}

From source file:com.conferenceengineer.android.iosched.ui.tablet.SessionsSandboxMultiPaneActivity.java

private void routeIntent(Intent intent, boolean updateSurfaceOnly) {
    Uri uri = intent.getData();//from  w  w w  . ja  v a  2  s  . c om
    if (uri == null) {
        return;
    }

    if (intent.hasExtra(Intent.EXTRA_TITLE)) {
        setTitle(intent.getStringExtra(Intent.EXTRA_TITLE));
    }

    String mimeType = getContentResolver().getType(uri);

    if (ScheduleContract.Tracks.CONTENT_ITEM_TYPE.equals(mimeType)) {
        // Load track details
        showFullUI(true);
        if (!updateSurfaceOnly) {
            // TODO: don't assume the URI will contain the track ID
            int defaultViewType = intent.getIntExtra(EXTRA_DEFAULT_VIEW_TYPE,
                    TracksDropdownFragment.VIEW_TYPE_SESSIONS);
            String selectedTrackId = ScheduleContract.Tracks.getTrackId(uri);
            loadTrackList(defaultViewType, selectedTrackId);
            onTrackSelected(selectedTrackId);
            mSlidingPaneLayout.openPane();
        }

    } else if (ScheduleContract.Sessions.CONTENT_TYPE.equals(mimeType)) {
        // Load a session list, hiding the tracks dropdown and the tabs
        mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS;
        showFullUI(false);
        if (!updateSurfaceOnly) {
            loadSessionList(uri, null);
            mSlidingPaneLayout.openPane();
        }

    } else if (ScheduleContract.Sessions.CONTENT_ITEM_TYPE.equals(mimeType)) {
        // Load session details
        if (intent.hasExtra(EXTRA_MASTER_URI)) {
            mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS;
            showFullUI(false);
            if (!updateSurfaceOnly) {
                loadSessionList((Uri) intent.getParcelableExtra(EXTRA_MASTER_URI),
                        ScheduleContract.Sessions.getSessionId(uri));
                loadSessionDetail(uri);
            }
        } else {
            mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS; // prepare for onTrackInfo...
            showFullUI(true);
            if (!updateSurfaceOnly) {
                loadSessionDetail(uri);
                loadTrackInfoFromSessionUri(uri);
            }
        }

    }

    updateDetailBackground();
}

From source file:com.nextgis.firereporter.GetFiresService.java

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

    if (intent == null)
        return START_REDELIVER_INTENT;

    int nCommnad = intent.getIntExtra(COMMAND, SERVICE_START);

    SharedPreferences prefs = getSharedPreferences(MainActivity.PREFERENCES, MODE_PRIVATE | MODE_MULTI_PROCESS);
    long nUpdateInterval = prefs.getLong(SettingsActivity.KEY_PREF_INTERVAL + "_long",
            30 * DateUtils.MINUTE_IN_MILLIS); //15
    boolean bEnergyEconomy = prefs.getBoolean(SettingsActivity.KEY_PREF_SERVICE_BATT_SAVE, true);

    Log.d(MainActivity.TAG, "Received intent - id " + startId + ": " + intent + ", command:" + nCommnad);

    if ((nCommnad & SERVICE_START) != 0) {
        mUserNasaReceiver = intent.getParcelableExtra(RECEIVER);
        if (mUserNasaReceiver != null) {
            mnFilter = intent.getIntExtra(SOURCE, MainActivity.SRC_NASA | MainActivity.SRC_USER);

            if (mnCurrentExec < 1) {
                mUserNasaReceiver.send(SERVICE_START, new Bundle());
            }//from  w w w . j  a  va  2 s  .  c o  m
            Log.d(MainActivity.TAG, "GetFiresService service started");
            if ((mnFilter & MainActivity.SRC_NASA) != 0) {
                mnCurrentExec++;
                GetNasaData(false);
            }

            if ((mnFilter & MainActivity.SRC_USER) != 0) {
                mnCurrentExec++;
                GetUserData(false);
            }
        }
        // plan next start
        ScheduleNextUpdate(this, SERVICE_START | SERVICE_SCANEXSTART, nUpdateInterval, bEnergyEconomy);
    }

    if ((nCommnad & SERVICE_SCANEXSTART) != 0) {
        mScanexReceiver = intent.getParcelableExtra(RECEIVER_SCANEX);
        if (mScanexReceiver != null) {
            if (mnCurrentExec < 1) {
                mScanexReceiver.send(SERVICE_SCANEXSTART, new Bundle());
            }
            Log.d(MainActivity.TAG, "GetFiresService service started");
            GetScanexData(false);
        }
        // plan next start
        ScheduleNextUpdate(this, SERVICE_START | SERVICE_SCANEXSTART, nUpdateInterval, bEnergyEconomy);

    }

    if ((nCommnad & SERVICE_STOP) != 0) {
        Log.d(MainActivity.TAG, "GetFiresService service stopped");
        ScheduleNextUpdate(this, SERVICE_DESTROY, 150, true);
        stopSelf();
    }

    if ((nCommnad & SERVICE_DESTROY) != 0) {
        stopSelf();
    }

    if ((nCommnad & SERVICE_DATA) != 0) {
        mUserNasaReceiver = intent.getParcelableExtra(RECEIVER);
        for (FireItem item : mmoFires.values()) {
            SendItem(item);
        }
    }

    if ((nCommnad & SERVICE_SCANEXDATA) != 0) {
        mScanexReceiver = intent.getParcelableExtra(RECEIVER_SCANEX);
        for (ScanexSubscriptionItem Item : mmoSubscriptions.values()) {
            SendScanexItem(Item);
        }
    }

    if ((nCommnad & SERVICE_SCANEXDATAUPDATE) != 0) {
        long nSubscirbeId = intent.getLongExtra(SUBSCRIPTION_ID, -1);
        long nNotificationId = intent.getLongExtra(NOTIFICATION_ID, -1);
        ScanexSubscriptionItem subscribe = mmoSubscriptions.get(nSubscirbeId);
        if (subscribe != null) {
            ScanexNotificationItem notification = subscribe.GetItems().get(nNotificationId);
            if (notification != null) {
                notification.setWatched(true);
            }
        }
    }

    if ((nCommnad & SERVICE_NOTIFY_DISMISSED) != 0) {
        nUserCount = 0;
        nNasaCount = 0;
        nScanexCount = 0;

        mInboxStyle = new NotificationCompat.InboxStyle();
        mInboxStyle.setBigContentTitle(getString(R.string.stNewFireNotificationDetailes));

        ScheduleNextUpdate(this, SERVICE_START | SERVICE_SCANEXSTART, nUpdateInterval, bEnergyEconomy);
    }

    return START_REDELIVER_INTENT;
}

From source file:com.battlelancer.seriesguide.api.SeriesGuideExtension.java

@Override
protected void onHandleIntent(Intent intent) {
    if (intent == null) {
        return;/*from  w  w  w.  j  av  a  2  s.c o m*/
    }

    String action = intent.getAction();
    if (ACTION_SUBSCRIBE.equals(action)) {
        // just subscribing or unsubscribing
        handleSubscribe((ComponentName) intent.getParcelableExtra(EXTRA_SUBSCRIBER_COMPONENT),
                intent.getStringExtra(EXTRA_TOKEN));
    } else if (ACTION_UPDATE.equals(action)) {
        // subscriber requests an updated action
        if (intent.hasExtra(EXTRA_ENTITY_IDENTIFIER) && intent.hasExtra(EXTRA_EPISODE)) {
            handleEpisodeRequest(intent.getIntExtra(EXTRA_ENTITY_IDENTIFIER, 0),
                    intent.getBundleExtra(EXTRA_EPISODE));
        }
    }
}

From source file:com.android.deskclock.timer.TimerFragment.java

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

    // Start watching for page changes away from this fragment.
    getDeskClock().registerPageChangedListener(this);

    // Initialize the page indicators.
    updatePageIndicators();/* ww  w  .  java  2 s.c o m*/

    boolean createTimer = false;
    int showTimerId = -1;

    // Examine the intent of the parent activity to determine which view to display.
    final Intent intent = getActivity().getIntent();
    if (intent != null) {
        // These extras are single-use; remove them after honoring them.
        createTimer = intent.getBooleanExtra(EXTRA_TIMER_SETUP, false);
        intent.removeExtra(EXTRA_TIMER_SETUP);

        showTimerId = intent.getIntExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, -1);
        intent.removeExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID);
    }

    // Choose the view to display in this fragment.
    if (showTimerId != -1) {
        // A specific timer must be shown; show the list of timers.
        showTimersView();
    } else if (!hasTimers() || createTimer || mTimerSetupState != null) {
        // No timers exist, a timer is being created, or the last view was timer setup;
        // show the timer setup view.
        showCreateTimerView();

        if (mTimerSetupState != null) {
            mCreateTimerView.setState(mTimerSetupState);
            mTimerSetupState = null;
        }
    } else {
        // Otherwise, default to showing the list of timers.
        showTimersView();
    }

    // If the intent did not specify a timer to show, show the last timer that expired.
    if (showTimerId == -1) {
        final Timer timer = DataModel.getDataModel().getMostRecentExpiredTimer();
        showTimerId = timer == null ? -1 : timer.getId();
    }

    // If a specific timer should be displayed, display the corresponding timer tab.
    if (showTimerId != -1) {
        final Timer timer = DataModel.getDataModel().getTimer(showTimerId);
        if (timer != null) {
            final int index = DataModel.getDataModel().getTimers().indexOf(timer);
            mViewPager.setCurrentItem(index);
        }
    }
}