List of usage examples for android.os Bundle getParcelable
@Nullable public <T extends Parcelable> T getParcelable(@Nullable String key)
From source file:com.github.chenxiaolong.dualbootpatcher.patcher.PatchFileFragment.java
/** * {@inheritDoc}//ww w . j a v a 2s .c o m */ @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null) { mSelectedPatcherId = savedInstanceState.getString(EXTRA_SELECTED_PATCHER_ID); mSelectedInputUri = savedInstanceState.getParcelable(EXTRA_SELECTED_INPUT_URI); mSelectedOutputUri = savedInstanceState.getParcelable(EXTRA_SELECTED_OUTPUT_URI); mSelectedInputFileName = savedInstanceState.getString(EXTRA_SELECTED_INPUT_FILE_NAME); mSelectedInputFileSize = savedInstanceState.getLong(EXTRA_SELECTED_INPUT_FILE_SIZE); mSelectedTaskId = savedInstanceState.getInt(EXTRA_SELECTED_TASK_ID); mSelectedDevice = savedInstanceState.getParcelable(EXTRA_SELECTED_DEVICE); mSelectedRomId = savedInstanceState.getString(EXTRA_SELECTED_ROM_ID); mQueryingMetadata = savedInstanceState.getBoolean(EXTRA_QUERYING_METADATA); } // Initialize UI elements mRecycler = (RecyclerView) getActivity().findViewById(R.id.files_list); mFAB = (FloatingActionMenu) getActivity().findViewById(R.id.fab); mFABAddZip = (FloatingActionButton) getActivity().findViewById(R.id.fab_add_flashable_zip); mFABAddOdin = (FloatingActionButton) getActivity().findViewById(R.id.fab_add_odin_image); mProgressBar = (ProgressBar) getActivity().findViewById(R.id.loading); mAddZipMessage = (TextView) getActivity().findViewById(R.id.add_zip_message); mItemTouchCallback = new DragSwipeItemTouchCallback(this); ItemTouchHelper itemTouchHelper = new ItemTouchHelper(mItemTouchCallback); itemTouchHelper.attachToRecyclerView(mRecycler); // Disable change animation since we frequently update the progress, which makes the // animation very ugly ItemAnimator animator = mRecycler.getItemAnimator(); if (animator instanceof SimpleItemAnimator) { ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false); } // Set up listener for the FAB mFABAddZip.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { startFileSelection(PatcherUtils.PATCHER_ID_MULTIBOOTPATCHER); mFAB.close(true); } }); mFABAddOdin.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { startFileSelection(PatcherUtils.PATCHER_ID_ODINPATCHER); mFAB.close(true); } }); // Set up adapter for the files list mAdapter = new PatchFileItemAdapter(getActivity(), mItems, this); mRecycler.setHasFixedSize(true); mRecycler.setAdapter(mAdapter); LinearLayoutManager llm = new LinearLayoutManager(getActivity()); llm.setOrientation(LinearLayoutManager.VERTICAL); mRecycler.setLayoutManager(llm); // Hide FAB initially mFAB.hideMenuButton(false); // Show loading progress bar updateLoadingStatus(); // Initialize the patcher once the service is connected executeNeedsService(new Runnable() { @Override public void run() { mService.initializePatcher(); } }); // NOTE: No further loading should be done here. All initialization should be done in // onPatcherLoaded(), which is called once the patcher's data files have been extracted and // loaded. }
From source file:ro.tudorluca.gpstracks.android.MainActivity.java
/** * Updates fields based on data stored in the bundle. * * @param savedInstanceState The activity state saved in the Bundle. *//*from www. j av a 2s .c om*/ private void updateValuesFromBundle(Bundle savedInstanceState) { Log.i(TAG, "Updating values from bundle"); if (savedInstanceState != null) { // Update the value of mRequestingLocationUpdates from the Bundle, and make sure that // the Start Updates and Stop Updates buttons are correctly enabled or disabled. if (savedInstanceState.keySet().contains(REQUESTING_LOCATION_UPDATES_KEY)) { mRequestingLocationUpdates = savedInstanceState.getBoolean(REQUESTING_LOCATION_UPDATES_KEY); setButtonsEnabledState(); } // Update the value of mCurrentLocation from the Bundle and update the UI to show the // correct latitude and longitude. if (savedInstanceState.keySet().contains(LOCATION_KEY)) { // Since LOCATION_KEY was found in the Bundle, we can be sure that mCurrentLocation // is not null. mCurrentLocation = savedInstanceState.getParcelable(LOCATION_KEY); } // Update the value of mLastUpdateTime from the Bundle and update the UI. if (savedInstanceState.keySet().contains(LAST_UPDATED_TIME_STRING_KEY)) { mLastUpdateTime = savedInstanceState.getString(LAST_UPDATED_TIME_STRING_KEY); } updateUI(); } }
From source file:com.android.dialer.voicemail.VoicemailPlaybackPresenter.java
/** * Update variables which are activity-dependent or state-dependent. *///from www . j a v a 2 s .com protected void init(Activity activity, Bundle savedInstanceState) { mActivity = activity; mContext = activity; mInitialOrientation = mContext.getResources().getConfiguration().orientation; mActivity.setVolumeControlStream(VoicemailAudioManager.PLAYBACK_STREAM); if (savedInstanceState != null) { // Restores playback state when activity is recreated, such as after rotation. mVoicemailUri = (Uri) savedInstanceState.getParcelable(VOICEMAIL_URI_KEY); mIsPrepared = savedInstanceState.getBoolean(IS_PREPARED_KEY); mPosition = savedInstanceState.getInt(CLIP_POSITION_KEY, 0); mIsPlaying = savedInstanceState.getBoolean(IS_PLAYING_STATE_KEY, false); mIsSpeakerphoneOn = savedInstanceState.getBoolean(IS_SPEAKERPHONE_ON_KEY, false); } if (mMediaPlayer == null) { mIsPrepared = false; mIsPlaying = false; } }
From source file:br.com.rescue_bots_android.bluetooth.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_blue); ActivityHelper.initialize(this); routeController = new RouteController(this); coordinates = new ArrayList<Path>(); trackerController = new TrackerController(this); Intent intent = getIntent();//www . j a v a 2 s.c o m Bundle b = intent.getExtras(); mDevice = b.getParcelable(Homescreen.DEVICE_EXTRA); mDeviceUUID = UUID.fromString(b.getString(Homescreen.DEVICE_UUID)); mMaxChars = b.getInt(Homescreen.BUFFER_SIZE); Log.d(TAG, "Ready"); mBtnDisconnect = (Button) findViewById(R.id.btnDisconnect); mBtnSend = (Button) findViewById(R.id.btnSend); mBtnClear = (Button) findViewById(R.id.btnClear); mTxtReceive = (TextView) findViewById(R.id.txtReceive); mEditSend = (EditText) findViewById(R.id.editSend); scrollView = (ScrollView) findViewById(R.id.viewScroll); chkScroll = (CheckBox) findViewById(R.id.chkScroll); chkReceiveText = (CheckBox) findViewById(R.id.chkReceiveText); checkBoxJoystickEnable = (CheckBox) findViewById(R.id.checkBoxJoystickEnable); mBtnClearInput = (Button) findViewById(R.id.btnClearInput); mBtnConfig = (Button) findViewById(R.id.buttonConfig2); //imageButtonClaw (Button)findViewById(R.id.imageButtonClaw); editTextAngle = (TextView) findViewById(R.id.editTextAngle); joystickView = (JoystickView) findViewById(R.id.viewJoystick); //Event listener that always returns the variation of the angle in degrees, motion power in percentage and direction of movement ibClaw = (ImageButton) findViewById(R.id.imageButtonClaw); clawControll = new ClawControll(ibClaw); joystickView.setOnJoystickMoveListener(new OnJoystickMoveListener() { @Override public void onValueChanged(int angle, int power, int direction) { // TODO Auto-generated method stub mTxtReceive.append(" " + String.valueOf(angle) + ""); mTxtReceive.append(" " + String.valueOf(power) + "%"); switch (direction) { case JoystickView.FRONT: mTxtReceive.append("FRONT"); sendSerial("a"); break; case JoystickView.FRONT_RIGHT: mTxtReceive.append("FRONT_RIGHT"); sendSerial("c"); break; case JoystickView.RIGHT: mTxtReceive.append("RIGHT"); sendSerial("c"); break; case JoystickView.RIGHT_BOTTOM: mTxtReceive.append("RIGHT_BOTTOM"); sendSerial("f"); break; case JoystickView.BOTTOM: mTxtReceive.append("BOTTOM"); sendSerial("d"); break; case JoystickView.BOTTOM_LEFT: mTxtReceive.append("BOTTOM_LEFT"); sendSerial("e"); break; case JoystickView.LEFT: mTxtReceive.append("LEFT"); sendSerial("b"); break; case JoystickView.LEFT_FRONT: mTxtReceive.append("LEFT_FRONT"); sendSerial("b"); break; default: mTxtReceive.append("CENTER"); sendSerial("g"); } } }, JoystickView.DEFAULT_LOOP_INTERVAL); mTxtReceive.setMovementMethod(new ScrollingMovementMethod()); mBtnDisconnect.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mIsUserInitiatedDisconnect = true; new DisConnectBT().execute(); } }); mBtnSend.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { try { mBTSocket.getOutputStream().write(mEditSend.getText().toString().getBytes()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); mBtnClear.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mEditSend.setText(""); } }); mBtnClearInput.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { //mTxtReceive.setText(""); if (mBtnClearInput.getText().toString().equalsIgnoreCase(LocationManager.GPS_PROVIDER)) { mBtnClearInput.setText(LocationManager.NETWORK_PROVIDER); gps.setProvider(LocationManager.NETWORK_PROVIDER); } else { mBtnClearInput.setText(LocationManager.GPS_PROVIDER); gps.setProvider(LocationManager.GPS_PROVIDER); } } }); mBtnConfig.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent i = new Intent(MainActivity.this, ConfigActivity.class); startActivity(i); } }); ibClaw.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (clawControll != null) { clawControll.changeState(); } } }); checkBoxJoystickEnable.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (checkBoxJoystickEnable.isChecked()) { joystickEnabled = true; joystickView.setEnabled(true); ibClaw.setEnabled(true); } else { joystickEnabled = false; joystickView.setEnabled(false); ibClaw.setEnabled(false); } } }); joystickView.setEnabled(true); ibClaw.setEnabled(true); initGPSListener(); // initialize your android device sensor capabilities mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); image = (ImageView) findViewById(R.id.compassImg); }
From source file:com.androidquery.simplefeed.activity.PostActivity.java
@Override protected void init(Bundle state) { Intent intent = getIntent();/*from w w w.j a v a2 s.c om*/ String message = ""; photo = (File) intent.getSerializableExtra("photo"); message = intent.getStringExtra("message"); if (state != null) { if (photo == null) { photo = (File) state.getSerializable("photo"); } if (message == null) { message = state.getString("message"); } location = state.getParcelable("location"); place = (Place) state.getSerializable("place"); tags = (List<Entity>) state.getSerializable("tags"); } entity = (Entity) intent.getSerializableExtra("entity"); item = (FeedItem) intent.getSerializableExtra("item"); initView(message); albumCheck(0); }
From source file:com.android.mail.browse.EmlViewerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.eml_viewer_activity); final ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); final Intent intent = getIntent(); final String action = intent.getAction(); final String type = intent.getType(); mAccountUri = intent.getParcelableExtra(EXTRA_ACCOUNT_URI); if (savedInstanceState == null) { if (Intent.ACTION_VIEW.equals(action) && MimeType.isEmlMimeType(type)) { final FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.add(R.id.eml_root, EmlMessageViewFragment.newInstance(intent.getData(), mAccountUri), FRAGMENT_TAG);//w ww. j av a 2 s . c om transaction.commit(); } else { LogUtils.wtf(LOG_TAG, "Entered EmlViewerActivity with wrong intent action or type: %s, %s", action, type); finish(); // we should not be here. bail out. bail out. return; } } else { if (savedInstanceState.containsKey(SAVED_ACCOUNT)) { mAccount = savedInstanceState.getParcelable(SAVED_ACCOUNT); } } // Account uri will be null if we launched from outside of the app. // So just don't load an account at all. if (mAccountUri != null) { getLoaderManager().initLoader(ACCOUNT_LOADER, Bundle.EMPTY, mAccountLoadCallbacks); } }
From source file:com.chuhan.privatecalc.fragment.os.FragmentActivity.java
/** * Perform initialization of all fragments and loaders. *//*from www .j av a 2 s . co m*/ @Override protected void onCreate(Bundle savedInstanceState) { mFragments.attachActivity(this, mContainer, null); // Old versions of the platform didn't do this! if (getLayoutInflater().getFactory() == null) { getLayoutInflater().setFactory(this); } super.onCreate(savedInstanceState); NonConfigurationInstances nc = (NonConfigurationInstances) getLastNonConfigurationInstance(); if (nc != null) { mAllLoaderManagers = nc.loaders; } if (savedInstanceState != null) { Parcelable p = savedInstanceState.getParcelable(FRAGMENTS_TAG); mFragments.restoreAllState(p, nc != null ? nc.fragments : null); } mFragments.dispatchCreate(); }
From source file:com.github.jberkel.pay.me.IabHelper.java
/** * Initiate the UI flow for an in-app purchase. Call this method to initiate an in-app purchase, * which will involve bringing up the Google Play screen. The calling activity will be paused while * the user interacts with Google Play, and the result will be delivered via the activity's * {@link android.app.Activity#onActivityResult} method, at which point you must call * this object's {@link #handleActivityResult} method to continue the purchase flow. This method * MUST be called from the UI thread of the Activity. * * @param activity The calling activity. * @param sku The sku of the item to purchase. * @param itemType indicates if it's a product or a subscription * @param requestCode A request code (to differentiate from other responses -- * as in {@link android.app.Activity#startActivityForResult}). * @param listener The listener to notify when the purchase process finishes, can be null * @param developerPayload Extra data (developer payload), which will be returned with the purchase data * when the purchase completes. This extra data will be permanently bound to that purchase * and will always be returned when the purchase is queried. *//* ww w . j a va 2 s . c o m*/ public void launchPurchaseFlow(final Activity activity, final String sku, final ItemType itemType, final int requestCode, final OnIabPurchaseFinishedListener listener, final String developerPayload) { if (TextUtils.isEmpty(sku)) throw new IllegalArgumentException("Empty sku"); if (itemType == null) throw new IllegalArgumentException("Empty itemType"); if (isDisposed()) { if (listener != null) { listener.onIabPurchaseFinished(new IabResult(Response.IABHELPER_DISPOSED), null); } return; } checkSetupDone("launchPurchaseFlow"); flagStartAsync("launchPurchaseFlow"); if (itemType == SUBS && !mSubscriptionsSupported || itemType == INAPP && !mInAppSupported) { flagEndAsync(); if (listener != null) { listener.onIabPurchaseFinished( new IabResult( itemType == INAPP ? BILLING_UNAVAILABLE : IABHELPER_SUBSCRIPTIONS_NOT_AVAILABLE), null); } return; } try { logDebug("Constructing buy intent for " + sku + ", item type: " + itemType); Bundle buyIntentBundle = mService.getBuyIntent(API_VERSION, mContext.getPackageName(), sku, itemType.toString(), developerPayload); int response = getResponseCodeFromBundle(buyIntentBundle); if (response != OK.code) { logError("Unable to buy item, Error response: " + getDescription(response)); flagEndAsync(); if (listener != null) { listener.onIabPurchaseFinished(new IabResult(response, "Unable to buy item"), null); } return; } PendingIntent pendingIntent = buyIntentBundle.getParcelable(RESPONSE_BUY_INTENT); if (pendingIntent == null) { throw new SendIntentException("No pending intent"); } logDebug("Launching buy intent for " + sku + ". Request code: " + requestCode); mPurchaseFlowState = new PurchaseFlowState(requestCode, itemType, listener); activity.startIntentSenderForResult(pendingIntent.getIntentSender(), requestCode, new Intent(), 0, 0, 0); } catch (SendIntentException e) { logError("SendIntentException while launching purchase flow for sku " + sku, e); flagEndAsync(); if (listener != null) listener.onIabPurchaseFinished(new IabResult(IABHELPER_SEND_INTENT_FAILED), null); } catch (RemoteException e) { logError("RemoteException while launching purchase flow for sku " + sku, e); flagEndAsync(); if (listener != null) listener.onIabPurchaseFinished(new IabResult(IABHELPER_REMOTE_EXCEPTION), null); } }
From source file:com.markupartist.sthlmtraveling.RoutesActivity.java
/** * Restores the search routes task./*from ww w. j a v a 2 s.c o m*/ * @param savedInstanceState the saved state */ private void restoreJourneyQuery(Bundle savedInstanceState) { if (savedInstanceState.containsKey(EXTRA_JOURNEY_QUERY)) { mJourneyQuery = savedInstanceState.getParcelable(EXTRA_JOURNEY_QUERY); } }
From source file:com.synox.android.ui.activity.FileActivity.java
/** * Loads the ownCloud {@link Account} and main {@link OCFile} to be handled by the instance of * the {@link FileActivity}./* w w w . j av a 2s . c o m*/ * <p/> * Grants that a valid ownCloud {@link Account} is associated to the instance, or that the user * is requested to create a new one. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mHandler = new Handler(); mFileOperationsHelper = new FileOperationsHelper(this); Account account = null; if (savedInstanceState != null) { mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE); mFromNotification = savedInstanceState.getBoolean(FileActivity.EXTRA_FROM_NOTIFICATION); mFileOperationsHelper .setOpIdWaitingFor(savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID, Long.MAX_VALUE)); if (getSupportActionBar() != null) { getSupportActionBar().setTitle(savedInstanceState.getString(KEY_ACTION_BAR_TITLE)); } } else { account = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT); mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE); mFromNotification = getIntent().getBooleanExtra(FileActivity.EXTRA_FROM_NOTIFICATION, false); } AccountUtils.updateAccountVersion(this); // best place, before any access to AccountManager // or database setAccount(account, savedInstanceState != null); mOperationsServiceConnection = new OperationsServiceConnection(); bindService(new Intent(this, OperationsService.class), mOperationsServiceConnection, Context.BIND_AUTO_CREATE); mDownloadServiceConnection = newTransferenceServiceConnection(); if (mDownloadServiceConnection != null) { bindService(new Intent(this, FileDownloader.class), mDownloadServiceConnection, Context.BIND_AUTO_CREATE); } mUploadServiceConnection = newTransferenceServiceConnection(); if (mUploadServiceConnection != null) { bindService(new Intent(this, FileUploader.class), mUploadServiceConnection, Context.BIND_AUTO_CREATE); } }