List of usage examples for android.os Bundle getBoolean
public boolean getBoolean(String key)
From source file:com.taw.gotothere.GoToThereActivity.java
@Override protected void onRestoreInstanceState(Bundle savedInstanceState) { // Let superclass handle map type/centre point and zoom level super.onRestoreInstanceState(savedInstanceState); Log.d(TAG, "onRestoreInstanceState()"); int latitude = savedInstanceState.getInt(END_LAT_KEY, -1); int longitude = savedInstanceState.getInt(END_LONG_KEY, -1); placingMarker = savedInstanceState.getBoolean(PLACING_MARKER_KEY); if (placingMarker) { startMarkerPlacement();// ww w . j a v a2 s.c om // May have tapped an endpoint already if (latitude != -1 && longitude != -1) { navigationOverlay.setSelectedLocation(new GeoPoint(latitude, longitude)); directionsImageView.setEnabled(true); } else { directionsImageView.setEnabled(false); } } navigating = savedInstanceState.getBoolean(NAVIGATING_KEY); if (navigating) { navigationOverlay.startNavigating(); if (latitude != -1 && longitude != -1) { navigationOverlay.setSelectedLocation(new GeoPoint(latitude, longitude)); } latitude = savedInstanceState.getInt(START_LAT_KEY, -1); longitude = savedInstanceState.getInt(START_LONG_KEY, -1); if (latitude != -1 && longitude != -1) { navigationOverlay.setStartLocation(new GeoPoint(latitude, longitude)); } navigationOverlay.setDirections((MapDirections) savedInstanceState.getSerializable(DIRECTIONS_KEY)); directionsImageView.setSelected(true); directionsImageView.setEnabled(true); markerImageView.setEnabled(false); } // Save the previousQuery flag as a preference: if the screen is re-oriented // then the activity is killed + restarted, meaning we lose the // savedInstanceState bundle. This is an easy way to keep track of this flag. SharedPreferences prefs = getPreferences(Activity.MODE_PRIVATE); searchTextView.setText(prefs.getString(PREVIOUS_QUERY, null)); }
From source file:com.mirasense.scanditsdk.plugin.ScanditSDK.java
private void scan(JSONArray data) { if (mPendingOperation) { return;// w ww . j a v a2s.c o m } mPendingOperation = true; mHandler.start(); final Bundle bundle = new Bundle(); try { bundle.putString(ScanditSDKParameterParser.paramAppKey, data.getString(0)); } catch (JSONException e) { Log.e("ScanditSDK", "Function called through Java Script contained illegal objects."); e.printStackTrace(); return; } if (data.length() > 1) { // We extract all options and add them to the intent extra bundle. try { setOptionsOnBundle(data.getJSONObject(1), bundle); } catch (JSONException e) { e.printStackTrace(); } } if (bundle.containsKey(ScanditSDKParameterParser.paramContinuousMode)) { mContinuousMode = bundle.getBoolean(ScanditSDKParameterParser.paramContinuousMode); } ScanditLicense.setAppKey(bundle.getString(ScanditSDKParameterParser.paramAppKey)); ScanditSDKGlobals.usedFramework = "phonegap"; if (bundle.containsKey(ScanditSDKParameterParser.paramPortraitMargins) || bundle.containsKey(ScanditSDKParameterParser.paramLandscapeMargins)) { cordova.getActivity().runOnUiThread(new Runnable() { public void run() { ScanSettings settings = ScanditSDKParameterParser.settingsForBundle(bundle); mBarcodePicker = new SearchBarBarcodePicker(cordova.getActivity(), settings); mBarcodePicker.setOnScanListener(ScanditSDK.this); mBarcodePicker.setOnSearchBarListener(ScanditSDK.this); mLayout = new RelativeLayout(cordova.getActivity()); ViewGroup viewGroup = getViewGroupToAddTo(); if (viewGroup != null) { viewGroup.addView(mLayout); } Display display = cordova.getActivity().getWindowManager().getDefaultDisplay(); ScanditSDKParameterParser.updatePickerUIFromBundle(mBarcodePicker, bundle, display.getWidth(), display.getHeight()); RelativeLayout.LayoutParams rLayoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); mLayout.addView(mBarcodePicker, rLayoutParams); adjustLayout(bundle, 0); if (bundle.containsKey(ScanditSDKParameterParser.paramPaused) && bundle.getBoolean(ScanditSDKParameterParser.paramPaused)) { mBarcodePicker.startScanning(true); } else { mBarcodePicker.startScanning(); } } }); } else { ScanditSDKResultRelay.setCallback(this); Intent intent = new Intent(cordova.getActivity(), ScanditSDKActivity.class); intent.putExtras(bundle); cordova.startActivityForResult(this, intent, 1); } }
From source file:cn.fulldroid.lib.datetimepicker.time.TimePickerDialog.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null && savedInstanceState.containsKey(KEY_HOUR_OF_DAY) && savedInstanceState.containsKey(KEY_MINUTE) && savedInstanceState.containsKey(KEY_IS_24_HOUR_VIEW)) { mInitialHourOfDay = savedInstanceState.getInt(KEY_HOUR_OF_DAY); mInitialMinute = savedInstanceState.getInt(KEY_MINUTE); mIs24HourMode = savedInstanceState.getBoolean(KEY_IS_24_HOUR_VIEW); mInKbMode = savedInstanceState.getBoolean(KEY_IN_KB_MODE); mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE); }//from w w w . j av a 2 s . c om }
From source file:br.liveo.navigationliveo.NavigationLiveoAWizard.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.navigation_main); if (savedInstanceState != null) { setCurrentPosition(savedInstanceState.getInt(CURRENT_POSITION)); //FORM WIZARD mWizardModel.load(savedInstanceState.getBundle("model")); mDataChanged = savedInstanceState.getBoolean("dataChanged"); }//from w w w . j a va 2s . co m mList = (ListView) findViewById(R.id.list); mList.setOnItemClickListener(new DrawerItemClickListener()); mToolbar = (Toolbar) findViewById(R.id.toolbar); // mToolbar.inflateMenu(R.menu.menu); ALVIN TEST mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); mDrawerToggle = new ActionBarDrawerToggleCompat(this, mDrawerLayout, mToolbar); mDrawerLayout.setDrawerListener(mDrawerToggle); mTitleFooter = (TextView) this.findViewById(R.id.titleFooter); mIconFooter = (ImageView) this.findViewById(R.id.iconFooter); mFooterDrawer = (RelativeLayout) this.findViewById(R.id.footerDrawer); mFooterDrawer.setOnClickListener(onClickFooterDrawer); mRelativeDrawer = (FrameLayout) this.findViewById(R.id.relativeDrawer); //alvin temp comments this.setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setIcon(R.drawable.ic_launcher); getSupportActionBar().setTitle(""); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { try { Resources.Theme theme = this.getTheme(); TypedArray typedArray = theme.obtainStyledAttributes(new int[] { android.R.attr.colorPrimary }); mDrawerLayout.setStatusBarBackground(typedArray.getResourceId(0, 0)); } catch (Exception e) { e.getMessage(); } this.setElevationToolBar(15); } if (mList != null) { mountListNavigation(savedInstanceState); } if (savedInstanceState == null) { mNavigationListener.onItemClickNavigation(mCurrentPosition, R.id.container); } setCheckedItemNavigation(mCurrentPosition, true); }
From source file:com.android.datetimepicker.time.TimePickerDialog.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null && savedInstanceState.containsKey(KEY_HOUR_OF_DAY) && savedInstanceState.containsKey(KEY_MINUTE) && savedInstanceState.containsKey(KEY_IS_24_HOUR_VIEW)) { mInitialHourOfDay = savedInstanceState.getInt(KEY_HOUR_OF_DAY); mInitialMinute = savedInstanceState.getInt(KEY_MINUTE); mIs24HourMode = savedInstanceState.getBoolean(KEY_IS_24_HOUR_VIEW); mInKbMode = savedInstanceState.getBoolean(KEY_IN_KB_MODE); mThemeDark = savedInstanceState.getBoolean(KEY_DARK_THEME); }/*from w w w . j a v a 2s . c o m*/ }
From source file:at.wada811.android.dialogfragments.AlertDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (!isFromBuilder) { throw new RuntimeException("Use AlertDialogFragment$Builder"); }//from ww w. j a v a 2 s . c om final Bundle args = getArguments(); final int theme = args.getInt(THEME); AlertDialog.Builder builder; if (theme == VALUE_NULL || Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { builder = new AlertDialog.Builder(getActivity()); } else { builder = newDialogBuilder(theme); } iconId = args.getInt(ICON_ID, VALUE_NULL); if (iconId != VALUE_NULL) { builder.setIcon(iconId); } final CharSequence title = args.getCharSequence(TITLE); boolean useCustomTitle = args.getBoolean(CUSTOM_TITLE); if (title != null) { builder.setTitle(title); } else if (useCustomTitle) { setCustomTitle(builder); } final CharSequence message = args.getCharSequence(MESSAGE); if (message != null) { builder.setMessage(message); } final int useInverseBackground = args.getInt(INVERSE_BACKGROUND); if (useInverseBackground != VALUE_NULL) { builder.setInverseBackgroundForced(useInverseBackground == VALUE_TRUE); } // View setView(builder); // List setItems(builder); setAdapter(builder); setSingleChoiceItems(builder); setMultiChoiceItems(builder); // Buttons setPositiveButton(builder); setNeutralButton(builder); setNegativeButton(builder); // Build return builder.create(); }
From source file:es.upv.riromu.arbre.main.MainActivity.java
@Override protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); if (savedInstanceState.containsKey("cropping")) { state[CROP_IMAGE] = savedInstanceState.getBoolean("cropping"); }//from www .j a v a 2 s. com if (savedInstanceState.containsKey("treated")) { state[TREAT_IMAGE] = savedInstanceState.getBoolean("treated"); } if (savedInstanceState.containsKey("image_uri")) { image_uri = Uri.parse(savedInstanceState.getString("image_uri")); } if (savedInstanceState.getBoolean("image")) { String fileName = "temp_image.jpg"; String fileURL = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath() + "/" + fileName; File file = new File(fileURL); try { InputStream imageStream = getContentResolver().openInputStream(Uri.fromFile(file)); image = Util.decodeScaledBitmapFromFile(file.getPath(), MAX_SIZE, MAX_SIZE); // image = BitmapFactory.decodeStream(imageStream); } catch (FileNotFoundException e) { Log.e(TAG, e.getMessage()); } } if (state[CROP_IMAGE]) { String fileName = "temp_cropped.jpg"; String fileURL = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath() + "/" + fileName; File file = new File(fileURL); try { InputStream imageStream = getContentResolver().openInputStream(Uri.fromFile(file)); croppedimage = BitmapFactory.decodeStream(imageStream); imageStream.close(); } catch (FileNotFoundException e) { Log.e(TAG, e.getMessage()); } catch (IOException e) { Log.e(TAG, e.getMessage()); } } if (state[TREAT_IMAGE]) { String fileName = "temp_treated.jpg"; String fileURL = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath() + "/" + fileName; File file = new File(fileURL); try { InputStream imageStream = getContentResolver().openInputStream(Uri.fromFile(file)); ImageView imv = (ImageView) findViewById(R.id.image_intro); imv.setImageBitmap(BitmapFactory.decodeStream(imageStream)); imageStream.close(); } catch (FileNotFoundException e) { Log.e(TAG, e.getMessage()); } catch (IOException e) { Log.e(TAG, e.getMessage()); } } ImageView imv = (ImageView) findViewById(R.id.image_intro); colours = savedInstanceState.getIntArray("colours"); if ((!state[TREAT_IMAGE]) && state[CROP_IMAGE]) imv.setImageBitmap(croppedimage); else { imv.setImageBitmap(image); } TextView imc = (TextView) findViewById(R.id.textView); imc.setBackgroundColor(Color.rgb(colours[COLOUR_R], colours[COLOUR_G], colours[COLOUR_B])); }
From source file:com.example.alvarpao.popularmovies.MovieGridFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Add the below line in order for this fragment to display and handle menu options. setHasOptionsMenu(true);/* w ww .j a va2 s . c o m*/ if (savedInstanceState != null) { //State needs to be restored for this activity, a rotation occurred if (savedInstanceState.containsKey(LOADED_MOVIES)) mMovies = savedInstanceState.getParcelableArrayList(LOADED_MOVIES); if (savedInstanceState.containsKey(PAGE_TO_FETCH)) mPageToFetch = savedInstanceState.getInt(PAGE_TO_FETCH); if (savedInstanceState.containsKey(LOADED_PREVIOUS_ITEMS)) mPreviousTotalItems = savedInstanceState.getInt(LOADED_PREVIOUS_ITEMS); if (savedInstanceState.containsKey(SELECTION_OCCURRED)) mSelectionOccurred = savedInstanceState.getBoolean(SELECTION_OCCURRED); if (savedInstanceState.containsKey(CURRENT_SCROLL_POSITION)) mCurrentScrollPosition = savedInstanceState.getInt(CURRENT_SCROLL_POSITION); } else mMovies = new ArrayList<Movie>(); }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
/** * EventBus listener//from ww w .jav a 2 s. co m * @param {Location} location */ @Subscribe public void onEventMainThread(Location location) { JSONObject locationData = BackgroundGeolocationService.locationToJson(location, currentActivity); Bundle meta = location.getExtras(); if (meta != null) { String action = meta.getString("action"); boolean motionChanged = action.equalsIgnoreCase(BackgroundGeolocationService.ACTION_ON_MOTION_CHANGE); if (motionChanged) { boolean nowMoving = meta.getBoolean("isMoving"); onMotionChange(nowMoving, locationData); } } this.onLocationChange(locationData); }