List of usage examples for android.os Bundle getSerializable
@Override
@Nullable
public Serializable getSerializable(@Nullable String key)
From source file:com.commonsware.android.camcon.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState == null) { output = new File(new File(getFilesDir(), PHOTOS), FILENAME); if (output.exists()) { output.delete();/* ww w .j av a 2s . co m*/ } else { output.getParentFile().mkdirs(); } Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Uri outputUri = FileProvider.getUriForFile(this, AUTHORITY, output); i.putExtra(MediaStore.EXTRA_OUTPUT, outputUri); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { i.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { ClipData clip = ClipData.newUri(getContentResolver(), "A photo", outputUri); i.setClipData(clip); i.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); } else { List<ResolveInfo> resInfoList = getPackageManager().queryIntentActivities(i, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; grantUriPermission(packageName, outputUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION); } } try { startActivityForResult(i, CONTENT_REQUEST); } catch (ActivityNotFoundException e) { Toast.makeText(this, R.string.msg_no_camera, Toast.LENGTH_LONG).show(); finish(); } } else { output = (File) savedInstanceState.getSerializable(EXTRA_FILENAME); } }
From source file:com.afstd.sqlitecommander.app.filemanager.FMFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_fm, container, false); fListView = (ListView) view.findViewById(R.id.list); tvPath = (TextView) view.findViewById(R.id.tvPath); path = savedInstanceState != null ? savedInstanceState.getString(CURR_DIR) : FMUtils.FILE_SEPARATOR;//Environment.getExternalStorageDirectory().toString(); tvPath.setText(path);//from www .java2s. co m fListView.setDrawingCacheEnabled(true); fAdapter = new FMAdapter(getActivity(), new ArrayList<FMEntry>()); fListView.setAdapter(fAdapter); ls(path, false); fListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) { FMEntry entry = fAdapter.getItem(pos); if (entry.getType() == FMEntry.TYPE_DIRECTORY || entry.getType() == FMEntry.TYPE_DIRECTORY_LINK) { Parcelable state = fListView.onSaveInstanceState(); listScrollStates.put(path, state); backstack.add(path); path = entry.getType() == FMEntry.TYPE_DIRECTORY_LINK ? entry.getLink() : entry.getPath(); validatePath(); ls(path, false); } else if (entry.getType() == FMEntry.TYPE_FILE || entry.getType() == FMEntry.TYPE_LINK) { SQLiteCMDActivity.start(getActivity(), entry.getPath(), true); } } }); if (savedInstanceState != null) { backstack = (LinkedList<String>) savedInstanceState.getSerializable(BACKSTACK); Parcelable listState = savedInstanceState.getParcelable("list_position"); if (listState != null) fListView.post(new RestoreListStateRunnable(listState)); } return view; }
From source file:com.wmstein.transektcount.CountOptionsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_count_options); transektCount = (TransektCountApplication) getApplication(); prefs = com.wmstein.transektcount.TransektCountApplication.getPrefs(); prefs.registerOnSharedPreferenceChangeListener(this); boolean brightPref = prefs.getBoolean("pref_bright", true); // Set full brightness of screen if (brightPref) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); WindowManager.LayoutParams params = getWindow().getAttributes(); params.screenBrightness = 1.0f;// www .j a v a 2 s . c om getWindow().setAttributes(params); } ScrollView counting_screen = (ScrollView) findViewById(R.id.count_options); bMap = transektCount.decodeBitmap(R.drawable.kbackground, transektCount.width, transektCount.height); bg = new BitmapDrawable(counting_screen.getResources(), bMap); counting_screen.setBackground(bg); static_widget_area = (LinearLayout) findViewById(R.id.static_widget_area); dynamic_widget_area = (LinearLayout) findViewById(R.id.dynamic_widget_area); Bundle extras = getIntent().getExtras(); if (extras != null) { count_id = extras.getInt("count_id"); section_id = extras.getInt("section_id"); } savedAlerts = new ArrayList<>(); if (savedInstanceState != null) { if (savedInstanceState.getSerializable("savedAlerts") != null) { savedAlerts = (ArrayList<AlertCreateWidget>) savedInstanceState.getSerializable("savedAlerts"); } } }
From source file:com.stasbar.knowyourself.timer.TimerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { TimerFragmentBinding bindiner = TimerFragmentBinding.inflate(inflater, container, false); View view = bindiner.getRoot(); mViewPager = bindiner.verticalViewPager; mCreateTimerView = bindiner.timerSetup; btnStartPause = bindiner.buttonStartPauseActivity; btnStop = bindiner.buttonStopActivity; mAdapter = new TimerPagerAdapter(getChildFragmentManager()); mViewPager.setAdapter(mAdapter);//from w w w.j a v a 2s . co m mViewPager.addOnPageChangeListener(mTimerPageChangeListener); mTimersView = view.findViewById(R.id.timer_view); mPageIndicators = new ImageView[] { (ImageView) view.findViewById(R.id.page_indicator0), (ImageView) view.findViewById(R.id.page_indicator1), (ImageView) view.findViewById(R.id.page_indicator2), (ImageView) view.findViewById(R.id.page_indicator3) }; DataModel.getDataModel().addTimerListener(mAdapter); DataModel.getDataModel().addTimerListener(mTimerWatcher); // If timer setup state is present, retrieve it to be later honored. if (savedInstanceState != null) { mTimerSetupState = savedInstanceState.getSerializable(KEY_TIMER_SETUP_STATE); } return view; }
From source file:com.ebridgevas.android.ebridgeapp.messaging.mqttservice.MqttAndroidClient.java
/** * Process notification of a published message having been delivered * /* w ww . ja v a2s . com*/ * @param data */ private void messageDeliveredAction(Bundle data) { IMqttToken token = removeMqttToken(data); if (token != null) { if (callback != null) { Status status = (Status) data.getSerializable(MqttServiceConstants.CALLBACK_STATUS); if (status == Status.OK && token instanceof IMqttDeliveryToken) { callback.deliveryComplete((IMqttDeliveryToken) token); } } } }
From source file:com.stfalcon.contentmanager.ContentManager.java
/** * Call to reinitialize the helpers instance state. * Need to call in onRestoreInstanceState method of activity *//*from ww w . ja va 2 s .c o m*/ public void onRestoreInstanceState(Bundle savedInstanceState) { if (savedInstanceState != null) { if (savedInstanceState.containsKey(DATE_CAMERA_INTENT_STARTED_STATE)) { dateCameraIntentStarted = stringToDate( savedInstanceState.getString(DATE_CAMERA_INTENT_STARTED_STATE)); } if (savedInstanceState.containsKey(CAMERA_PIC_URI_STATE)) { preDefinedCameraUri = Uri.parse(savedInstanceState.getString(CAMERA_PIC_URI_STATE)); } if (savedInstanceState.containsKey(PHOTO_URI_STATE)) { photoUri = Uri.parse(savedInstanceState.getString(PHOTO_URI_STATE)); } if (savedInstanceState.containsKey(ROTATE_X_DEGREES_STATE)) { rotateXDegrees = savedInstanceState.getInt(ROTATE_X_DEGREES_STATE); } if (savedInstanceState.containsKey(TARGET_FILE_STATE)) { targetFile = (File) savedInstanceState.getSerializable(TARGET_FILE_STATE); } if (savedInstanceState.containsKey(SAVED_CONTENT_STATE)) { savedContent = (Content) savedInstanceState.getSerializable(SAVED_CONTENT_STATE); } if (savedInstanceState.containsKey(SAVED_TASK_STATE)) { savedTask = savedInstanceState.getInt(SAVED_TASK_STATE); } } }
From source file:com.wdullaer.materialdatetimepicker.date.DatePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { int listPosition = -1; int listPositionOffset = 0; int currentView = mDefaultView; if (savedInstanceState != null) { mWeekStart = savedInstanceState.getInt(KEY_WEEK_START); mMinYear = savedInstanceState.getInt(KEY_YEAR_START); mMaxYear = savedInstanceState.getInt(KEY_YEAR_END); currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW); listPosition = savedInstanceState.getInt(KEY_LIST_POSITION); listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET); mMinDate = (Calendar) savedInstanceState.getSerializable(KEY_MIN_DATE); mMaxDate = (Calendar) savedInstanceState.getSerializable(KEY_MAX_DATE); highlightedDays = (HashSet<Calendar>) savedInstanceState.getSerializable(KEY_HIGHLIGHTED_DAYS); selectableDays = (TreeSet<Calendar>) savedInstanceState.getSerializable(KEY_SELECTABLE_DAYS); disabledDays = (HashSet<Calendar>) savedInstanceState.getSerializable(KEY_DISABLED_DAYS); mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK); mThemeDarkChanged = savedInstanceState.getBoolean(KEY_THEME_DARK_CHANGED); mAccentColor = savedInstanceState.getInt(KEY_ACCENT); mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE); mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS); mAutoDismiss = savedInstanceState.getBoolean(KEY_AUTO_DISMISS); mTitle = savedInstanceState.getString(KEY_TITLE); mOkResid = savedInstanceState.getInt(KEY_OK_RESID); mOkString = savedInstanceState.getString(KEY_OK_STRING); mOkColor = savedInstanceState.getInt(KEY_OK_COLOR); mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID); mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING); mCancelColor = savedInstanceState.getInt(KEY_CANCEL_COLOR); mVersion = (Version) savedInstanceState.getSerializable(KEY_VERSION); mTimezone = (TimeZone) savedInstanceState.getSerializable(KEY_TIMEZONE); }/* w w w .j av a 2 s. co m*/ int viewRes = mVersion == Version.VERSION_1 ? R.layout.mdtp_date_picker_dialog : R.layout.mdtp_date_picker_dialog_v2; View view = inflater.inflate(viewRes, container, false); // All options have been set at this point: round the initial selection if necessary setToNearestDate(mCalendar); mDatePickerHeaderView = (TextView) view.findViewById(R.id.mdtp_date_picker_header); mMonthAndDayView = (LinearLayout) view.findViewById(R.id.mdtp_date_picker_month_and_day); mMonthAndDayView.setOnClickListener(this); mSelectedMonthTextView = (TextView) view.findViewById(R.id.mdtp_date_picker_month); mSelectedDayTextView = (TextView) view.findViewById(R.id.mdtp_date_picker_day); mYearView = (TextView) view.findViewById(R.id.mdtp_date_picker_year); mYearView.setOnClickListener(this); final Activity activity = getActivity(); mDayPickerView = new SimpleDayPickerView(activity, this); mYearPickerView = new YearPickerView(activity, this); // if theme mode has not been set by java code, check if it is specified in Style.xml if (!mThemeDarkChanged) { mThemeDark = Utils.isDarkTheme(activity, mThemeDark); } Resources res = getResources(); mDayPickerDescription = res.getString(R.string.mdtp_day_picker_description); mSelectDay = res.getString(R.string.mdtp_select_day); mYearPickerDescription = res.getString(R.string.mdtp_year_picker_description); mSelectYear = res.getString(R.string.mdtp_select_year); int bgColorResource = mThemeDark ? R.color.mdtp_date_picker_view_animator_dark_theme : R.color.mdtp_date_picker_view_animator; view.setBackgroundColor(ContextCompat.getColor(activity, bgColorResource)); mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.mdtp_animator); mAnimator.addView(mDayPickerView); mAnimator.addView(mYearPickerView); mAnimator.setDateMillis(mCalendar.getTimeInMillis()); // TODO: Replace with animation decided upon by the design team. Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(ANIMATION_DURATION); mAnimator.setInAnimation(animation); // TODO: Replace with animation decided upon by the design team. Animation animation2 = new AlphaAnimation(1.0f, 0.0f); animation2.setDuration(ANIMATION_DURATION); mAnimator.setOutAnimation(animation2); Button okButton = (Button) view.findViewById(R.id.mdtp_ok); okButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); notifyOnDateListener(); dismiss(); } }); okButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); if (mOkString != null) okButton.setText(mOkString); else okButton.setText(mOkResid); Button cancelButton = (Button) view.findViewById(R.id.mdtp_cancel); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); if (getDialog() != null) getDialog().cancel(); } }); cancelButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); if (mCancelString != null) cancelButton.setText(mCancelString); else cancelButton.setText(mCancelResid); cancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE); // If an accent color has not been set manually, get it from the context if (mAccentColor == -1) { mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity()); } if (mDatePickerHeaderView != null) mDatePickerHeaderView.setBackgroundColor(Utils.darkenColor(mAccentColor)); view.findViewById(R.id.mdtp_day_picker_selected_date_layout).setBackgroundColor(mAccentColor); // Buttons can have a different color if (mOkColor != -1) okButton.setTextColor(mOkColor); else okButton.setTextColor(mAccentColor); if (mCancelColor != -1) cancelButton.setTextColor(mCancelColor); else cancelButton.setTextColor(mAccentColor); if (getDialog() == null) { view.findViewById(R.id.mdtp_done_background).setVisibility(View.GONE); } updateDisplay(false); setCurrentView(currentView); if (listPosition != -1) { if (currentView == MONTH_AND_DAY_VIEW) { mDayPickerView.postSetSelection(listPosition); } else if (currentView == YEAR_VIEW) { mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset); } } mHapticFeedbackController = new HapticFeedbackController(activity); return view; }
From source file:com.skplanet.c3po.scheduler.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Stetho.initialize(/*from w ww . j av a2 s. com*/ Stetho.newInitializerBuilder(this).enableDumpapp(Stetho.defaultDumperPluginsProvider(this)) .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this)).build()); setContentView(R.layout.main_activity); // Get the UI widgets. mRequestActivityUpdatesButton = (Button) findViewById(R.id.request_activity_updates_button); mRemoveActivityUpdatesButton = (Button) findViewById(R.id.remove_activity_updates_button); mDetectedActivitiesListView = (ListView) findViewById(R.id.detected_activities_listview); // Get a receiver for broadcasts from ActivityDetectionIntentService. mBroadcastReceiver = new ActivityDetectionBroadcastReceiver(); // Enable either the Request Updates button or the Remove Updates button depending on // whether activity updates have been requested. setButtonsEnabledState(); // Reuse the value of mDetectedActivities from the bundle if possible. This maintains state // across device orientation changes. If mDetectedActivities is not stored in the bundle, // populate it with DetectedActivity objects whose confidence is set to 0. Doing this // ensures that the bar graphs for only only the most recently detected activities are // filled in. if (savedInstanceState != null && savedInstanceState.containsKey(Constants.DETECTED_ACTIVITIES)) { mDetectedActivities = (ArrayList<DetectedActivity>) savedInstanceState .getSerializable(Constants.DETECTED_ACTIVITIES); } else { mDetectedActivities = new ArrayList<DetectedActivity>(); // Set the confidence level of each monitored activity to zero. for (int i = 0; i < Constants.MONITORED_ACTIVITIES.length; i++) { mDetectedActivities.add(new DetectedActivity(Constants.MONITORED_ACTIVITIES[i], 0)); } } // Bind the adapter to the ListView responsible for display data for detected activities. mAdapter = new DetectedActivitiesAdapter(this, mDetectedActivities); mDetectedActivitiesListView.setAdapter(mAdapter); // Kick off the request to build GoogleApiClient. // buildGoogleApiClient(); }
From source file:co.taqat.call.assistant.AssistantActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getResources().getBoolean(R.bool.orientation_portrait_only)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }/*from w w w . j a va 2s.c o m*/ setContentView(R.layout.assistant); initUI(); if (getIntent().getBooleanExtra("LinkPhoneNumber", false)) { isLink = true; //if (getIntent().getBooleanExtra("FromPref",false)){ // fromPref = true; //displayCreateAccount(); } else { firstFragment = getResources().getBoolean(R.bool.assistant_use_linphone_login_as_first_fragment) ? AssistantFragmentsEnum.LINPHONE_LOGIN : AssistantFragmentsEnum.WELCOME; if (findViewById(R.id.fragment_container) != null) { if (savedInstanceState == null) { display(firstFragment); } else { currentFragment = (AssistantFragmentsEnum) savedInstanceState .getSerializable("CurrentFragment"); } } } if (savedInstanceState != null && savedInstanceState.containsKey("echoCanceller")) { echoCancellerAlreadyDone = savedInstanceState.getBoolean("echoCanceller"); } else { echoCancellerAlreadyDone = false; } mPrefs = LinphonePreferences.instance(); status.enableSideMenu(false); accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl()); accountCreator.setDomain(getResources().getString(R.string.default_domain)); accountCreator.setListener(this); countryListAdapter = new CountryListAdapter(getApplicationContext()); mListener = new LinphoneCoreListenerBase() { @Override public void configuringStatus(LinphoneCore lc, final LinphoneCore.RemoteProvisioningState state, String message) { if (progress != null) progress.dismiss(); if (state == LinphoneCore.RemoteProvisioningState.ConfiguringSuccessful) { goToLinphoneActivity(); } else if (state == LinphoneCore.RemoteProvisioningState.ConfiguringFailed) { Toast.makeText(AssistantActivity.instance(), getString(R.string.remote_provisioning_failure), Toast.LENGTH_LONG).show(); } } @Override public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, RegistrationState state, String smessage) { if (remoteProvisioningInProgress) { if (progress != null) progress.dismiss(); if (state == RegistrationState.RegistrationOk) { remoteProvisioningInProgress = false; success(); } } else if (accountCreated && !newAccount) { if (address != null && address.asString().equals(cfg.getAddress().asString())) { if (state == RegistrationState.RegistrationOk) { if (progress != null) progress.dismiss(); if (LinphoneManager.getLc().getDefaultProxyConfig() != null) { accountCreator.isAccountUsed(); } } else if (state == RegistrationState.RegistrationFailed) { if (progress != null) progress.dismiss(); if (dialog == null || !dialog.isShowing()) { dialog = createErrorDialog(cfg, smessage); dialog.show(); } } else if (!(state == RegistrationState.RegistrationProgress)) { if (progress != null) progress.dismiss(); } } } } }; instance = this; }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
@SuppressWarnings("unchecked") protected void restoreInstance(Bundle b) { if (b == null) return;//from w w w .j a v a 2s . c o m historyFilterDevices = (String[]) b.getSerializable("historyFilterDevices"); historyFilterNetworks = (String[]) b.getSerializable("historyFilterNetworks"); historyFilterDevicesFilter = (ArrayList<String>) b.getSerializable("historyFilterDevicesFilter"); historyFilterNetworksFilter = (ArrayList<String>) b.getSerializable("historyFilterNetworksFilter"); historyItemList.clear(); historyItemList.addAll((ArrayList<Map<String, String>>) b.getSerializable("historyItemList")); historyStorageList.clear(); historyStorageList.addAll((ArrayList<Map<String, String>>) b.getSerializable("historyStorageList")); historyResultLimit = b.getInt("historyResultLimit"); currentMapOptions.clear(); currentMapOptions.putAll((HashMap<String, String>) b.getSerializable("currentMapOptions")); currentMapOptionTitles = (HashMap<String, String>) b.getSerializable("currentMapOptionTitles"); mapTypeListSectionList = (ArrayList<MapListSection>) b.getSerializable("mapTypeListSectionList"); mapFilterListSectionListMap = (HashMap<String, List<MapListSection>>) b .getSerializable("mapFilterListSectionListMap"); currentMapType = (MapListEntry) b.getSerializable("currentMapType"); }