List of usage examples for android.content Intent getBooleanExtra
public boolean getBooleanExtra(String name, boolean defaultValue)
From source file:cmput301.f13t01.readstory.ReadFragmentActivity.java
/** * Called when the activity is first created. Receives intent from main * activity to create the first fragment. *//*from w ww . j a va2 s . co m*/ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); app = (GlobalManager) getApplication(); save = GlobalManager.getLocalManager(); setContentView(R.layout.activity_view_fragment); // if it is not starting from beginning, start reading according to // history if (savedInstanceState != null) { storyId = (UUID) savedInstanceState.getSerializable(getResources().getString(R.string.story_id)); app.setStoryManager(storyId); this.storyManager = app.getStoryManager(); fragmentId = storyManager.getMostRecent(); } else { // intent has the story ID, and story fragment ID to display Intent intent = getIntent(); // receive id of story fragment to show storyId = (UUID) intent.getSerializableExtra(getResources().getString(R.string.story_id)); // set the story in the story manager app.setStoryManager(storyId); this.storyManager = app.getStoryManager(); // depending if we are reading from beginning, // fetch the appropriate fragment ID accordingly Boolean fromBeginning = (boolean) intent .getBooleanExtra(getResources().getString(R.string.story_continue), false); if (fromBeginning) { storyManager.clearHistory(); fragmentId = storyManager.getFirstPageId(); } else { // show first page if the story has never been read fragmentId = storyManager.getMostRecent(); if (fragmentId == null) { fragmentId = storyManager.getFirstPageId(); } } // if there is no first page set, exit readmode if (fragmentId == null) { Toast.makeText(getBaseContext(), "First page has not been set for this story!", Toast.LENGTH_LONG) .show(); finish(); } } commitFragment(fragmentId); }
From source file:com.bt.download.android.gui.activities.MainActivity.java
private boolean isShutdown(Intent intent) { if (intent == null) { return false; }//from w w w . ja v a 2 s . c o m if (intent.getBooleanExtra("shutdown-" + ConfigurationManager.instance().getUUIDString(), false)) { finish(); Engine.instance().shutdown(); return true; } return false; }
From source file:com.heightechllc.breakify.MainActivity.java
/** * Handles a new intent, either from onNewIntent() or onCreate() * @param intent The intent to handle/*from w w w. ja v a 2s.c om*/ * @return Whether we should attempt to restore the saved timer state. Will be false when * this method opens another Activity. */ private boolean handleIntent(Intent intent) { boolean shouldRestoreSavedTimer = true; if (intent.getBooleanExtra(EXTRA_SNOOZE, false)) { // The activity was launched from the expanded notification's "Snooze" action snoozeTimer(); // In case user didn't interact with the RingingActivity, and instead snoozed directly // from the notification AlarmRinger.stop(this); // Don't restore, since we're about to open a new Activity shouldRestoreSavedTimer = false; } else if (intent.getBooleanExtra(EXTRA_ALARM_RING, false)) { // The Activity was launched from AlarmReceiver, meaning the timer finished and we // need to ring the alarm Intent ringingIntent = new Intent(this, RingingActivity.class); // Pass along FLAG_ACTIVITY_NO_USER_ACTION if it was set when calling this activity if ((intent.getFlags() & Intent.FLAG_ACTIVITY_NO_USER_ACTION) != 0) ringingIntent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION); startActivityForResult(ringingIntent, RingingActivity.REQUEST_ALARM_RING); // Don't restore, since we're about to open a new Activity shouldRestoreSavedTimer = false; } else if (intent.getBooleanExtra(EXTRA_SCHEDULED_START, false)) { // The Activity was launched from ScheduledStartReceiver, meaning it's time for the // scheduled start // Show a dialog prompting the user to start new AlertDialog.Builder(this).setTitle(R.string.scheduled_dialog_title) .setMessage(R.string.scheduled_dialog_message) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { // Start the timer circleTimer.performClick(); } }).setNeutralButton(R.string.action_settings, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { // Show the settings activity with the Scheduled Start settings Intent intent = new Intent(MainActivity.this, SettingsActivity.class); intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, ScheduledStartSettingsFragment.class.getName()); intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_TITLE, R.string.pref_category_scheduled); startActivity(intent); } }).setNegativeButton(R.string.cancel, null).show(); } return shouldRestoreSavedTimer; }
From source file:edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticatorActivity.java
/** * {@inheritDoc}/*from ww w . j av a 2 s . c o m*/ */ @Override public void onCreate(Bundle icicle) { if (BuildConfig.DEBUG) { Log.i(TAG, "onCreate(" + icicle + ")"); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { requestWindowFeature(Window.FEATURE_ACTION_BAR); } super.onCreate(icicle); mAccountManager = AccountManager.get(this); if (BuildConfig.DEBUG) { Log.i(TAG, "loading data from Intent"); } final Intent intent = getIntent(); mUsername = intent.getStringExtra(EXTRA_USERNAME); mAuthtokenType = intent.getStringExtra(EXTRA_AUTHTOKEN_TYPE); mRequestNewAccount = mUsername == null; mConfirmCredentials = intent.getBooleanExtra(EXTRA_CONFIRMCREDENTIALS, false); if (BuildConfig.DEBUG) { Log.i(TAG, " request new: " + mRequestNewAccount); } requestWindowFeature(Window.FEATURE_LEFT_ICON); final CharSequence appName = getAppName(); // make the title based on the app name. setTitle(getString(R.string.login_title, appName)); // TODO make this changeable. Maybe use fragments? setContentView(R.layout.login); // this is done this way, so the associated icon is managed in XML. try { getWindow().setFeatureDrawable(Window.FEATURE_LEFT_ICON, getPackageManager().getActivityIcon(getComponentName())); } catch (final NameNotFoundException e) { e.printStackTrace(); } mMessage = (TextView) findViewById(R.id.message); mUsernameEdit = (EditText) findViewById(R.id.username); mUsernameEdit.setHint(isEmailAddressLogin() ? R.string.auth_email_login_hint : R.string.auth_username_hint); mPasswordEdit = (EditText) findViewById(R.id.password); mPasswordEdit.setOnEditorActionListener(this); findViewById(R.id.login).setOnClickListener(this); findViewById(R.id.cancel).setOnClickListener(this); mRegisterButton = (Button) findViewById(R.id.register); mRegisterButton.setOnClickListener(this); final String regButton = getString(R.string.signup_text, appName); if (regButton.length() < 24) { mRegisterButton.setText(regButton); } ((TextView) findViewById(R.id.username_label)).setText(getString(R.string.username_label, appName)); mUsernameEdit.setText(mUsername); // this will be unnecessary with fragments mAuthenticationTask = (AuthenticationTask) getLastNonConfigurationInstance(); if (mAuthenticationTask != null) { mAuthenticationTask.attach(this); } }
From source file:com.mobicage.rogerthat.NewsActivity.java
private void processNewsReceived(Intent intent, final NewsListAdapter nla) { if (swipeContainer.isRefreshing()) { swipeContainer.setRefreshing(false); resetUpdatesAvailable(nla, (Button) findViewById(R.id.updates_available)); } else if (isCurrentFeed(intent.getStringExtra("feed_name"))) { final boolean isInitial = intent.getBooleanExtra("initial", false); if (!isInitial) { final long[] newIds = intent.getLongArrayExtra("new_ids"); if (newIds != null) { for (long newsId : newIds) { mNewNewsItems.add(newsId); }//from ww w. j a v a 2 s .c om if (newIds.length > 0) { setupUpdatesAvailable(); } } final long[] updatedIds = intent.getLongArrayExtra("updated_ids"); if (updatedIds != null) { nla.updateNewsItems(updatedIds); } } } }
From source file:com.android.managedprovisioning.DeviceOwnerProvisioningActivity.java
private void handleProvisioningIntent(Intent intent) { String action = intent.getAction(); if (action.equals(DeviceOwnerProvisioningService.ACTION_PROVISIONING_SUCCESS)) { if (DEBUG) ProvisionLogger.logd("Successfully provisioned"); onProvisioningSuccess();//from w ww .j av a2s . c o m } else if (action.equals(DeviceOwnerProvisioningService.ACTION_PROVISIONING_ERROR)) { int errorMessageId = intent.getIntExtra(DeviceOwnerProvisioningService.EXTRA_USER_VISIBLE_ERROR_ID_KEY, R.string.device_owner_error_general); boolean factoryResetRequired = intent .getBooleanExtra(DeviceOwnerProvisioningService.EXTRA_FACTORY_RESET_REQUIRED, true); if (DEBUG) { ProvisionLogger.logd("Error reported with code " + getResources().getString(errorMessageId)); } error(errorMessageId, factoryResetRequired); } else if (action.equals(DeviceOwnerProvisioningService.ACTION_PROGRESS_UPDATE)) { int progressMessage = intent.getIntExtra(DeviceOwnerProvisioningService.EXTRA_PROGRESS_MESSAGE_ID_KEY, -1); if (DEBUG) { ProvisionLogger .logd("Progress update reported with code " + getResources().getString(progressMessage)); } if (progressMessage >= 0) { progressUpdate(progressMessage); } } }
From source file:com.smithdtyler.prettygoodmusicplayer.NowPlaying.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent originIntent = getIntent(); if (originIntent.getBooleanExtra("From_Notification", false)) { String artistName = originIntent.getStringExtra(ArtistList.ARTIST_NAME); String artistAbsPath = originIntent.getStringExtra(ArtistList.ARTIST_ABS_PATH_NAME); if (artistName != null && artistAbsPath != null) { Log.i(TAG, "Now Playing was launched from a notification, setting up its back stack"); // Reference: https://developer.android.com/reference/android/app/TaskStackBuilder.html TaskStackBuilder tsb = TaskStackBuilder.create(this); Intent intent = new Intent(this, ArtistList.class); tsb.addNextIntent(intent);//from www.j a v a2 s . com intent = new Intent(this, AlbumList.class); intent.putExtra(ArtistList.ARTIST_NAME, artistName); intent.putExtra(ArtistList.ARTIST_ABS_PATH_NAME, artistAbsPath); tsb.addNextIntent(intent); String albumName = originIntent.getStringExtra(AlbumList.ALBUM_NAME); if (albumName != null) { intent = new Intent(this, SongList.class); intent.putExtra(AlbumList.ALBUM_NAME, albumName); intent.putExtra(ArtistList.ARTIST_NAME, artistName); intent.putExtra(ArtistList.ARTIST_ABS_PATH_NAME, artistAbsPath); tsb.addNextIntent(intent); } intent = new Intent(this, NowPlaying.class); tsb.addNextIntent(intent); tsb.startActivities(); } } SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); String theme = sharedPref.getString("pref_theme", getString(R.string.light)); String size = sharedPref.getString("pref_text_size", getString(R.string.medium)); Log.i(TAG, "got configured theme " + theme); Log.i(TAG, "got configured size " + size); // These settings were fixed in english for a while, so check for old style settings as well as language specific ones. if (theme.equalsIgnoreCase(getString(R.string.dark)) || theme.equalsIgnoreCase("dark")) { Log.i(TAG, "setting theme to " + theme); if (size.equalsIgnoreCase(getString(R.string.small)) || size.equalsIgnoreCase("small")) { setTheme(R.style.PGMPDarkSmall); } else if (size.equalsIgnoreCase(getString(R.string.medium)) || size.equalsIgnoreCase("medium")) { setTheme(R.style.PGMPDarkMedium); } else { setTheme(R.style.PGMPDarkLarge); } } else if (theme.equalsIgnoreCase(getString(R.string.light)) || theme.equalsIgnoreCase("light")) { Log.i(TAG, "setting theme to " + theme); if (size.equalsIgnoreCase(getString(R.string.small)) || size.equalsIgnoreCase("small")) { setTheme(R.style.PGMPLightSmall); } else if (size.equalsIgnoreCase(getString(R.string.medium)) || size.equalsIgnoreCase("medium")) { setTheme(R.style.PGMPLightMedium); } else { setTheme(R.style.PGMPLightLarge); } } boolean fullScreen = sharedPref.getBoolean("pref_full_screen_now_playing", false); currentFullScreen = fullScreen; if (fullScreen) { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else { ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); } setContentView(R.layout.activity_now_playing); if (savedInstanceState == null) { doBindService(true); startPlayingRequired = true; } else { doBindService(false); startPlayingRequired = false; } // Get the message from the intent Intent intent = getIntent(); if (intent.getBooleanExtra(KICKOFF_SONG, false)) { desiredArtistName = intent.getStringExtra(ArtistList.ARTIST_NAME); desiredAlbumName = intent.getStringExtra(AlbumList.ALBUM_NAME); desiredArtistAbsPath = intent.getStringExtra(ArtistList.ARTIST_ABS_PATH_NAME); desiredSongAbsFileNames = intent.getStringArrayExtra(SongList.SONG_ABS_FILE_NAME_LIST); desiredAbsSongFileNamesPosition = intent.getIntExtra(SongList.SONG_ABS_FILE_NAME_LIST_POSITION, 0); desiredSongProgress = intent.getIntExtra(MusicPlaybackService.TRACK_POSITION, 0); Log.d(TAG, "Got song names " + desiredSongAbsFileNames + " position " + desiredAbsSongFileNamesPosition); TextView et = (TextView) findViewById(R.id.artistName); et.setText(desiredArtistName); et = (TextView) findViewById(R.id.albumName); et.setText(desiredAlbumName); } // The song name field will be set when we get our first update update from the service. final ImageButton pause = (ImageButton) findViewById(R.id.playPause); pause.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { playPause(); } }); ImageButton previous = (ImageButton) findViewById(R.id.previous); previous.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { previous(); } }); previous.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { jumpBack(); return true; } }); ImageButton next = (ImageButton) findViewById(R.id.next); next.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { next(); } }); final ImageButton shuffle = (ImageButton) findViewById(R.id.shuffle); shuffle.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { toggleShuffle(); } }); final ImageButton jumpback = (ImageButton) findViewById(R.id.jumpback); jumpback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { jumpBack(); } }); SeekBar seekBar = (SeekBar) findViewById(R.id.songProgressBar); seekBar.setEnabled(true); seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { private int requestedProgress; @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { Log.v(TAG, "drag location updated..." + progress); this.requestedProgress = progress; updateSongProgressLabel(progress); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { NowPlaying.this.userDraggingProgress = true; } @Override public void onStopTrackingTouch(SeekBar seekBar) { Message msg = Message.obtain(null, MusicPlaybackService.MSG_SEEK_TO); msg.getData().putInt(MusicPlaybackService.TRACK_POSITION, requestedProgress); try { Log.i(TAG, "Sending a request to seek!"); mService.send(msg); } catch (RemoteException e) { e.printStackTrace(); } NowPlaying.this.userDraggingProgress = false; } }); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("com.smithdtyler.ACTION_EXIT"); exitReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.i(TAG, "Received exit request, shutting down..."); Intent msgIntent = new Intent(getBaseContext(), MusicPlaybackService.class); msgIntent.putExtra("Message", MusicPlaybackService.MSG_STOP_SERVICE); startService(msgIntent); finish(); } }; registerReceiver(exitReceiver, intentFilter); }
From source file:org.ohthehumanity.carrie.CarrieActivity.java
/** Automatically called when an activity (our preferences) that was started with startActivityForResult exits **/ protected void onActivityResult(int requestCode, int resultCode, Intent data) { //if (data == null) { //Log.i(TAG, "Preferences closed no scan requested"); //} else {/*from www . java2s. c om*/ //Log.i(TAG, "Preferences closed scan is " + data.getBooleanExtra("scan", false)); //} if (data != null && data.getBooleanExtra("scan", false) == true) { //Log.i(TAG, "Begin scan in correct thread"); new ScanServersTask(this).execute(); } else { //Log.d(TAG, "Updating server name"); updateServerName(); } }
From source file:com.android.mms.transaction.MessagingNotification.java
public static boolean isFailedToDeliver(Intent intent) { return (intent != null) && intent.getBooleanExtra(UNDELIVERED_FLAG, false); }
From source file:com.android.mms.transaction.MessagingNotification.java
public static boolean isFailedToDownload(Intent intent) { return (intent != null) && intent.getBooleanExtra(FAILED_DOWNLOAD_FLAG, false); }