List of usage examples for android.os Bundle getParcelable
@Nullable public <T extends Parcelable> T getParcelable(@Nullable String key)
From source file:com.facebook.notifications.internal.asset.AssetManager.java
public AssetManager(@NonNull Parcel parcel) { registeredHandlers = new ConcurrentHashMap<>(); Bundle handlersBundle = parcel.readBundle(getClass().getClassLoader()); for (String type : handlersBundle.keySet()) { registeredHandlers.put(type, (ParcelableAssetHandler) handlersBundle.getParcelable(type)); }//from w w w. j av a 2 s.com }
From source file:cn.refactor.ultraindicator.lib.UltraIndicatorView.java
@Override protected void onRestoreInstanceState(Parcelable state) { if (state instanceof Bundle) { Bundle bundle = (Bundle) state; mCheckedPosition = bundle.getInt(KEY_INSTANCE_STATE); setCheckedPosition(mCheckedPosition); super.onRestoreInstanceState(bundle.getParcelable(KEY_INSTANCE_STATE)); return;/* w w w. j a va2 s .c o m*/ } super.onRestoreInstanceState(state); }
From source file:net.openid.appauth.AuthorizationManagementActivity.java
private void extractState(Bundle state) { if (state == null) { Logger.warn("No stored state - unable to handle response"); finish();// ww w .j a v a2 s .c om return; } mAuthIntent = state.getParcelable(KEY_AUTH_INTENT); mAuthorizationStarted = state.getBoolean(KEY_AUTHORIZATION_STARTED, false); try { String authRequestJson = state.getString(KEY_AUTH_REQUEST, null); mAuthRequest = authRequestJson != null ? AuthorizationRequest.jsonDeserialize(authRequestJson) : null; } catch (JSONException ex) { throw new IllegalStateException("Unable to deserialize authorization request", ex); } mCompleteIntent = state.getParcelable(KEY_COMPLETE_INTENT); mCancelIntent = state.getParcelable(KEY_CANCEL_INTENT); }
From source file:com.crossconnect.activity.main.SimpleLoaderTemplate.java
@Override public Loader<String> onCreateLoader(int id, Bundle args) { // This is called when a new Loader needs to be created. This // sample only has one Loader with no arguments, so it is simple. Log.i(TAG, "onCreateLoader()"); return new NotesListLoader(getActivity(), (BibleText) args.getParcelable("BibleText")); }
From source file:fr.cph.stock.android.activity.AccountActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.v(TAG, "Account Activity onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.account_activity); Bundle b = getIntent().getExtras(); portfolio = b.getParcelable("portfolio"); errorView = (TextView) findViewById(R.id.errorMessage); totalValueView = (TextView) findViewById(R.id.totalValue); totalGainView = (TextView) findViewById(R.id.totalGain); totalPlusMinusValueView = (TextView) findViewById(R.id.totalPlusMinusValue); lastUpateView = (TextView) findViewById(R.id.lastUpdate); liquidityView = (TextView) findViewById(R.id.liquidity); yieldYearView = (TextView) findViewById(R.id.yieldYear); shareValueView = (TextView) findViewById(R.id.shareValue); gainView = (TextView) findViewById(R.id.gain2); perfView = (TextView) findViewById(R.id.perf); yieldView = (TextView) findViewById(R.id.yieldPerf); taxesView = (TextView) findViewById(R.id.taxes); RelativeLayout accLayout = (RelativeLayout) findViewById(R.id.accountsLayout); TextView recent = new TextView(getApplicationContext()); textViews = new ArrayList<TextView>(); int id = 1;/*w w w . j a va 2 s.c o m*/ int nameID = 100; int viewId1 = 500; int currencyId = 1000; for (int i = 0; i < portfolio.getAccounts().size(); i++) { Account account = portfolio.getAccounts().get(i); TextView currentAccountNameTextView = new TextView(getApplicationContext()); currentAccountNameTextView.setText(account.getName()); currentAccountNameTextView.setTextColor(Color.GRAY); currentAccountNameTextView.setId(nameID); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT, (int) LayoutParams.WRAP_CONTENT); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); currentAccountNameTextView.setLayoutParams(params); accLayout.addView(currentAccountNameTextView, params); textViews.add(currentAccountNameTextView); View viewPoint1 = new View(getApplicationContext()); viewPoint1.setId(viewId1); viewPoint1.setBackgroundColor(getResources().getColor(R.color.grey_light)); params = new RelativeLayout.LayoutParams((int) LayoutParams.MATCH_PARENT, 2); params.addRule(RelativeLayout.RIGHT_OF, nameID); params.addRule(RelativeLayout.LEFT_OF, currencyId); params.setMargins(0, Util.convertDpToPxl(15, getApplicationContext()), 0, 0); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } viewPoint1.setLayoutParams(params); accLayout.addView(viewPoint1, params); TextView currentCurrencyTextView = new TextView(getApplicationContext()); currentCurrencyTextView.setText(account.getCurrency()); currentCurrencyTextView.setTextColor(Color.GRAY); currentCurrencyTextView.setId(currencyId); params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT, (int) LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.CENTER_HORIZONTAL); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } currentCurrencyTextView.setLayoutParams(params); accLayout.addView(currentCurrencyTextView, params); textViews.add(currentCurrencyTextView); View viewPoint2 = new View(getApplicationContext()); viewPoint2.setBackgroundColor(getResources().getColor(R.color.grey_light)); params = new RelativeLayout.LayoutParams((int) LayoutParams.MATCH_PARENT, 2); params.addRule(RelativeLayout.RIGHT_OF, currencyId); params.addRule(RelativeLayout.LEFT_OF, id); params.setMargins(0, Util.convertDpToPxl(15, getApplicationContext()), 0, 0); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } viewPoint2.setLayoutParams(params); accLayout.addView(viewPoint2, params); TextView currentTextView = new TextView(getApplicationContext()); currentTextView.setText(account.getLiquidity()); currentTextView.setTextColor(Color.GRAY); currentTextView.setId(id); params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT, (int) LayoutParams.WRAP_CONTENT); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); currentTextView.setLayoutParams(params); recent = currentTextView; accLayout.addView(currentTextView, params); textViews.add(currentTextView); id++; nameID++; viewId1++; currencyId++; } buildUi(false); // Set context EasyTracker.getInstance().setContext(getApplicationContext()); // Instantiate the Tracker tracker = EasyTracker.getTracker(); }
From source file:android.support.mediacompat.client.ClientBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { Bundle extras = intent.getExtras(); MediaControllerCompat controller;// www .ja va 2s .c o m try { controller = new MediaControllerCompat(context, (MediaSessionCompat.Token) extras.getParcelable(KEY_SESSION_TOKEN)); } catch (RemoteException ex) { // Do nothing. return; } int method = extras.getInt(KEY_METHOD_ID, 0); if (ACTION_CALL_MEDIA_CONTROLLER_METHOD.equals(intent.getAction()) && extras != null) { Bundle arguments; switch (method) { case SEND_COMMAND: arguments = extras.getBundle(KEY_ARGUMENT); controller.sendCommand(arguments.getString("command"), arguments.getBundle("extras"), new ResultReceiver(null)); break; case ADD_QUEUE_ITEM: controller.addQueueItem((MediaDescriptionCompat) extras.getParcelable(KEY_ARGUMENT)); break; case ADD_QUEUE_ITEM_WITH_INDEX: arguments = extras.getBundle(KEY_ARGUMENT); controller.addQueueItem((MediaDescriptionCompat) arguments.getParcelable("description"), arguments.getInt("index")); break; case REMOVE_QUEUE_ITEM: controller.removeQueueItem((MediaDescriptionCompat) extras.getParcelable(KEY_ARGUMENT)); break; case SET_VOLUME_TO: controller.setVolumeTo(extras.getInt(KEY_ARGUMENT), 0); break; case ADJUST_VOLUME: controller.adjustVolume(extras.getInt(KEY_ARGUMENT), 0); break; } } else if (ACTION_CALL_TRANSPORT_CONTROLS_METHOD.equals(intent.getAction()) && extras != null) { TransportControls controls = controller.getTransportControls(); Bundle arguments; switch (method) { case PLAY: controls.play(); break; case PAUSE: controls.pause(); break; case STOP: controls.stop(); break; case FAST_FORWARD: controls.fastForward(); break; case REWIND: controls.rewind(); break; case SKIP_TO_PREVIOUS: controls.skipToPrevious(); break; case SKIP_TO_NEXT: controls.skipToNext(); break; case SEEK_TO: controls.seekTo(extras.getLong(KEY_ARGUMENT)); break; case SET_RATING: controls.setRating((RatingCompat) extras.getParcelable(KEY_ARGUMENT)); break; case PLAY_FROM_MEDIA_ID: arguments = extras.getBundle(KEY_ARGUMENT); controls.playFromMediaId(arguments.getString("mediaId"), arguments.getBundle("extras")); break; case PLAY_FROM_SEARCH: arguments = extras.getBundle(KEY_ARGUMENT); controls.playFromSearch(arguments.getString("query"), arguments.getBundle("extras")); break; case PLAY_FROM_URI: arguments = extras.getBundle(KEY_ARGUMENT); controls.playFromUri((Uri) arguments.getParcelable("uri"), arguments.getBundle("extras")); break; case SEND_CUSTOM_ACTION: arguments = extras.getBundle(KEY_ARGUMENT); controls.sendCustomAction(arguments.getString("action"), arguments.getBundle("extras")); break; case SEND_CUSTOM_ACTION_PARCELABLE: arguments = extras.getBundle(KEY_ARGUMENT); controls.sendCustomAction((PlaybackStateCompat.CustomAction) arguments.getParcelable("action"), arguments.getBundle("extras")); break; case SKIP_TO_QUEUE_ITEM: controls.skipToQueueItem(extras.getLong(KEY_ARGUMENT)); break; case PREPARE: controls.prepare(); break; case PREPARE_FROM_MEDIA_ID: arguments = extras.getBundle(KEY_ARGUMENT); controls.prepareFromMediaId(arguments.getString("mediaId"), arguments.getBundle("extras")); break; case PREPARE_FROM_SEARCH: arguments = extras.getBundle(KEY_ARGUMENT); controls.prepareFromSearch(arguments.getString("query"), arguments.getBundle("extras")); break; case PREPARE_FROM_URI: arguments = extras.getBundle(KEY_ARGUMENT); controls.prepareFromUri((Uri) arguments.getParcelable("uri"), arguments.getBundle("extras")); break; case SET_CAPTIONING_ENABLED: controls.setCaptioningEnabled(extras.getBoolean(KEY_ARGUMENT)); break; case SET_REPEAT_MODE: controls.setRepeatMode(extras.getInt(KEY_ARGUMENT)); break; case SET_SHUFFLE_MODE: controls.setShuffleMode(extras.getInt(KEY_ARGUMENT)); break; } } }
From source file:ch.epfl.sweng.evento.gui.infinite_pager_adapter.InfiniteViewPager.java
@Override public void onRestoreInstanceState(final Parcelable state) { final InfinitePagerAdapter adapter = (InfinitePagerAdapter) getAdapter(); if (adapter == null) { if (Constants.DEBUG) { Log.w(LOG_TAG, "onRestoreInstanceState adapter == null"); }// w w w.j a va2 s. co m super.onRestoreInstanceState(state); return; } if (state instanceof Bundle) { Bundle bundle = (Bundle) state; final String representation = bundle.getString(ADAPTER_STATE); final Object c = adapter.convertToIndicator(representation); adapter.setCurrentIndicator(c); super.onRestoreInstanceState(bundle.getParcelable(SUPER_STATE)); return; } super.onRestoreInstanceState(state); }
From source file:com.android.volley.toolbox.AndroidAuthenticator.java
@SuppressWarnings("deprecation") @Override/*from w w w.jav a2 s .co m*/ public String getAuthToken() throws AuthFailureError { AccountManagerFuture<Bundle> future = mAccountManager.getAuthToken(mAccount, mAuthTokenType, mNotifyAuthFailure, null, null); Bundle result; try { result = future.getResult(); } catch (Exception e) { throw new AuthFailureError("Error while retrieving auth token", e); } String authToken = null; if (future.isDone() && !future.isCancelled()) { if (result.containsKey(AccountManager.KEY_INTENT)) { Intent intent = result.getParcelable(AccountManager.KEY_INTENT); throw new AuthFailureError(intent); } authToken = result.getString(AccountManager.KEY_AUTHTOKEN); } if (authToken == null) { throw new AuthFailureError("Got null auth token for type: " + mAuthTokenType); } return authToken; }
From source file:net.olejon.spotcommander.DonateActivity.java
private void makeDonation(final String product) { try {/*from w ww.j a va 2 s .c om*/ final Bundle buyIntentBundle = mIInAppBillingService.getBuyIntent(3, getPackageName(), product, "inapp", ""); final PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); final IntentSender intentSender = (pendingIntent != null) ? pendingIntent.getIntentSender() : null; startIntentSenderForResult(intentSender, 1, new Intent(), 0, 0, 0); } catch (Exception e) { mTools.showToast(getString(R.string.donate_something_went_wrong), 1); Log.e("DonateActivity", Log.getStackTraceString(e)); } }
From source file:com.blueserial.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ActivityHelper.initialize(this); Intent intent = getIntent();/*from w w w . j a v a2s . 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); jsonParser = new JSONParser(); url = "http://172.16.152.129/my_projects/android_database/add_sonar_data.php"; 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); mBtnClearInput = (Button) findViewById(R.id.btnClearInput); 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(""); } }); }