List of usage examples for android.content Intent getBooleanExtra
public boolean getBooleanExtra(String name, boolean defaultValue)
From source file:com.firefly.sample.castcompanionlibrary.notification.VideoCastNotificationService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { LOGD(TAG, "onStartCommand"); if (null != intent) { String action = intent.getAction(); if (ACTION_TOGGLE_PLAYBACK.equals(action) && mIsIcsOrAbove) { LOGD(TAG, "onStartCommand(): Action: ACTION_TOGGLE_PLAYBACK"); togglePlayback();/* www .j ava2 s.c o m*/ } else if (ACTION_STOP.equals(action) && mIsIcsOrAbove) { LOGD(TAG, "onStartCommand(): Action: ACTION_STOP"); stopApplication(); } else if (ACTION_VISIBILITY.equals(action)) { mVisible = intent.getBooleanExtra("visible", false); LOGD(TAG, "onStartCommand(): Action: ACTION_VISIBILITY " + mVisible); if (mVisible && null != mNotification) { startForeground(NOTIFICATION_ID, mNotification); } else { stopForeground(true); } } else { LOGD(TAG, "onStartCommand(): Action: none"); } } else { LOGD(TAG, "onStartCommand(): Intent was null"); } return Service.START_REDELIVER_INTENT; }
From source file:com.coact.kochzap.CaptureActivity.java
@Override protected void onResume() { super.onResume(); // historyManager must be initialized here to update the history preference historyManager = new HistoryManager(this); historyManager.trimHistory();// w w w . j a v a 2s . com // CameraManager must be initialized here, not in onCreate(). This is necessary because we don't // want to open the camera driver and measure the screen size if we're going to show the help on // first launch. That led to bugs where the scanning rectangle was the wrong size and partially // off screen. cameraManager = new CameraManager(getApplication()); viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); resultView = findViewById(R.id.result_view); statusView = (TextView) findViewById(R.id.status_view); handler = null; lastResult = null; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); resetStatusView(); beepManager.updatePrefs(); ambientLightManager.start(cameraManager); inactivityTimer.onResume(); Intent intent = getIntent(); copyToClipboard = prefs.getBoolean(PreferencesActivity.KEY_COPY_TO_CLIPBOARD, true) && (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true)); source = IntentSource.NONE; sourceUrl = null; scanFromWebPageManager = null; decodeFormats = null; characterSet = null; if (intent != null) { String action = intent.getAction(); String dataString = intent.getDataString(); if (Intents.Scan.ACTION.equals(action)) { // Scan the formats the intent requested, and return the result to the calling activity. 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); } } if (intent.hasExtra(Intents.Scan.CAMERA_ID)) { int cameraId = intent.getIntExtra(Intents.Scan.CAMERA_ID, -1); if (cameraId >= 0) { cameraManager.setManualCameraId(cameraId); } } String customPromptMessage = intent.getStringExtra(Intents.Scan.PROMPT_MESSAGE); if (customPromptMessage != null) { statusView.setText(customPromptMessage); } } else if (dataString != null && dataString.contains("http://www.google") && dataString.contains("/m/products/scan")) { // Scan only products and send the result to mobile Product Search. source = IntentSource.PRODUCT_SEARCH_LINK; sourceUrl = dataString; decodeFormats = DecodeFormatManager.PRODUCT_FORMATS; } else if (isZXingURL(dataString)) { // Scan formats requested in query string (all formats if none specified). // If a return URL is specified, send the results there. Otherwise, handle it ourselves. source = IntentSource.ZXING_LINK; sourceUrl = dataString; Uri inputUri = Uri.parse(dataString); scanFromWebPageManager = new ScanFromWebPageManager(inputUri); decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri); // Allow a sub-set of the hints to be specified by the caller. decodeHints = DecodeHintManager.parseDecodeHints(inputUri); } characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET); } SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { // The activity was paused but not stopped, so the surface still exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the camera. surfaceHolder.addCallback(this); } }
From source file:com.androidinspain.deskclock.timer.TimerFragment.java
@Override public void onStart() { super.onStart(); // Initialize the page indicators. updatePageIndicators();/*from ww w . j av a 2 s .c om*/ 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(TimerService.EXTRA_TIMER_ID, -1); intent.removeExtra(TimerService.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(FAB_AND_BUTTONS_IMMEDIATE); } 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(FAB_AND_BUTTONS_IMMEDIATE); if (mTimerSetupState != null) { mCreateTimerView.setState(mTimerSetupState); mTimerSetupState = null; } } else { // Otherwise, default to showing the list of timers. showTimersView(FAB_AND_BUTTONS_IMMEDIATE); } // 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); } } }
From source file:air.com.snagfilms.cast.chromecast.notifications.VideoCastNotificationService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d(TAG, "onStartCommand"); if (null != intent) { String action = intent.getAction(); if (ACTION_TOGGLE_PLAYBACK.equals(action) && mIsIcsOrAbove) { Log.d(TAG, "onStartCommand(): Action: ACTION_TOGGLE_PLAYBACK"); togglePlayback();/*from w w w . j av a2 s.co m*/ } else if (ACTION_STOP.equals(action) && mIsIcsOrAbove) { Log.d(TAG, "onStartCommand(): Action: ACTION_STOP"); stopApplication(); } else if (ACTION_VISIBILITY.equals(action)) { mVisible = intent.getBooleanExtra("visible", false); // mVisible=true; Log.d(TAG, "onStartCommand(): Action: ACTION_VISIBILITY " + mVisible); if (mVisible && null != mNotification) { startForeground(NOTIFICATION_ID, mNotification); } else { stopForeground(true); } } else { Log.d(TAG, "onStartCommand(): Action: none"); } } else { Log.d(TAG, "onStartCommand(): Intent was null"); } return Service.START_REDELIVER_INTENT; }
From source file:net.niyonkuru.koodroid.service.SessionService.java
@Override public void onHandleIntent(Intent intent) { if (DEBUG)//from w ww . jav a 2s . com Log.d(TAG, "onHandleIntent(intent=" + intent.toString() + ")"); int request = intent.getIntExtra(EXTRA_REQUEST, REQUEST_LOGIN); if (request == REQUEST_LOGOUT) { logout(); return; } final ResultReceiver receiver = intent.getParcelableExtra(EXTRA_STATUS_RECEIVER); final String email = intent.getStringExtra(EXTRA_EMAIL); final String password = intent.getStringExtra(EXTRA_PASSWORD); boolean broadcast = intent.getBooleanExtra(EXTRA_BROADCAST, false); /* totally ignore this request until full credentials are provided */ if (email == null || password == null) return; final long startLogin = System.currentTimeMillis(); final long lastLogin = mSettings.lastLogin(); /* if the last successful login is within the last 15 minutes */ if (startLogin - lastLogin <= DateUtils.MINUTE_IN_MILLIS * 15) { /* do a credentials check again the local data store */ if (email.equals(mSettings.email()) && password.equals(mSettings.password())) { if (broadcast) IntentUtils.callWidget(this, LOGIN_FINISHED); announce(receiver, STATUS_FINISHED); return; } } try { if (NetworkUtils.isConnected(this)) { /* announce to the caller that we are now running */ announce(receiver, STATUS_RUNNING); } else throw new ServiceException(getString(R.string.error_network_down)); if (mSettings.email() == null) { /* this is likely a new user */ Crittercism.leaveBreadcrumb(TAG + ": first_time_login"); } login(email, password); saveCookies(); if (DEBUG) Log.d(TAG, "login took " + (System.currentTimeMillis() - startLogin) + "ms"); } catch (IOException e) { if (DEBUG) Log.e(TAG, "Problem while logging in", e); /* if the exception was simply from an abort */ if (mPostRequest != null && mPostRequest.isAborted()) return; if (receiver != null) { // Pass back error to surface listener final Bundle bundle = new Bundle(); bundle.putString(Intent.EXTRA_TEXT, e.toString()); receiver.send(STATUS_ERROR, bundle); } return; /* do not announce success below */ } if (broadcast) IntentUtils.callWidget(this, LOGIN_FINISHED); announce(receiver, STATUS_FINISHED); }
From source file:com.owncloud.android.ui.activity.DrawerActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // update Account list and active account if Manage Account activity replies with // - ACCOUNT_LIST_CHANGED = true // - RESULT_OK if (requestCode == ACTION_MANAGE_ACCOUNTS && resultCode == RESULT_OK && data.getBooleanExtra(ManageAccountsActivity.KEY_ACCOUNT_LIST_CHANGED, false)) { // current account has changed if (data.getBooleanExtra(ManageAccountsActivity.KEY_CURRENT_ACCOUNT_CHANGED, false)) { setAccount(AccountUtils.getCurrentOwnCloudAccount(this)); restart();/*from w w w. ja v a2 s.c om*/ } else { updateAccountList(); updateQuota(); } } }
From source file:com.frostwire.android.gui.activities.MainActivity.java
private void updateNavigationMenu() { Intent intent = getIntent(); if (intent != null) { updateNavigationMenu(intent.getBooleanExtra("updateAvailable", false)); }//from w w w . j a va2 s. c o m }
From source file:com.androidaq.AndroiDAQMain.java
@Override public synchronized void onResume() { super.onResume(); if (D)//from w w w. ja v a 2s . c o m Log.e(TAG, "+ ON RESUME +"); Intent intent = getIntent(); intent.getBooleanExtra("firstopen", firstopen); updateFromPreferences(); // Performing this check in onResume() covers the case in which BT was // not enabled during onStart(), so we were paused to enable it... // onResume() will be called when ACTION_REQUEST_ENABLE activity returns. if (mSerialService != null) { // Only if the state is STATE_NONE, do we know that we haven't started already if (mSerialService.getState() == AndroiDAQService.STATE_NONE) { // Start the Bluetooth chat services mSerialService.start(); } } }
From source file:edu.mit.mobile.android.locast.data.Sync.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent != null) { if (Intent.ACTION_SYNC.equals(intent.getAction())) { if (intent.getBooleanExtra(EXTRA_EXPLICIT_SYNC, false)) { mNotifiedUserAboutNetworkStatus = true; mShouldAlertUserOnSuccess = true; }//w ww . j a v a 2 s . c om startSync(intent.getData(), intent.getExtras()); } else if (ACTION_CANCEL_SYNC.equals(intent.getAction())) { stopSync(); } } else { // restarted by system. startSync(); } return START_NOT_STICKY; }
From source file:ch.teamuit.android.soundplusplus.LibraryActivity.java
/** * Called by LibraryAdapters when a row has been clicked. * * @param rowData The data for the row that was clicked. *//* w w w . jav a2 s . c om*/ public void onItemClicked(Intent rowData) { int action = mDefaultAction; if (action == ACTION_LAST_USED) action = mLastAction; if (action == ACTION_EXPAND && rowData.getBooleanExtra(LibraryAdapter.DATA_EXPANDABLE, false)) { onItemExpanded(rowData); } else if (rowData.getLongExtra(LibraryAdapter.DATA_ID, LibraryAdapter.INVALID_ID) == mLastActedId) { openPlaybackActivity(); } else if (action != ACTION_DO_NOTHING) { if (action == ACTION_EXPAND) { // default to playing when trying to expand something that can't // be expanded action = ACTION_PLAY; } else if (action == ACTION_PLAY_OR_ENQUEUE) { action = (mState & PlaybackService.FLAG_PLAYING) == 0 ? ACTION_PLAY : ACTION_ENQUEUE; } pickSongs(rowData, action); } }