List of usage examples for android.os Bundle getParcelable
@Nullable public <T extends Parcelable> T getParcelable(@Nullable String key)
From source file:bottombar.BottomBarTab.java
@Override public void onRestoreInstanceState(Parcelable state) { if (state instanceof Bundle) { Bundle bundle = (Bundle) state; restoreState(bundle);//from ww w .j a v a 2s . com state = bundle.getParcelable("superstate"); } super.onRestoreInstanceState(state); }
From source file:click.kobaken.rxirohaandroid_sample.view.fragment.WalletFragment.java
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); String publicKey = null;//w ww . ja v a 2 s. c o m try { publicKey = KeyPair.getKeyPair(getContext()).publicKey; } catch (Exception e) { Log.e(TAG, "onActivityCreated: ", e); } transactionListAdapter = new TransactionListAdapter(getContext(), new ArrayList<>(), publicKey); binding.transactionList.setAdapter(transactionListAdapter); if (savedInstanceState != null) { transactionHistory = savedInstanceState.getParcelable(TransactionHistory.TAG); } }
From source file:com.cerema.cloud2.ui.preview.PreviewImageFragment.java
/** * {@inheritDoc}/* w w w . j a va2 s.co m*/ */ @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null) { if (!mIgnoreFirstSavedState) { OCFile file = savedInstanceState.getParcelable(PreviewImageFragment.EXTRA_FILE); setFile(file); } else { mIgnoreFirstSavedState = false; } } if (getFile() == null) { throw new IllegalStateException("Instanced with a NULL OCFile"); } if (!getFile().isDown()) { throw new IllegalStateException("There is no local file to preview"); } }
From source file:com.coloreight.plugin.socialAuth.SocialAuth.java
public void getTwitterSystemAccount(final String networkUserName, final CallbackContext callbackContext) { cordova.getThreadPool().execute(new Runnable() { public void run() { PluginResult pluginResult;/*from w w w . ja v a 2 s. c om*/ final JSONObject json = new JSONObject(); final JSONObject account = new JSONObject(); final Account[] twitterAccounts = accountManager .getAccountsByType("com.twitter.android.auth.login"); try { if (twitterAccounts.length > 0) { json.put("granted", true); for (int i = 0; i < twitterAccounts.length; i++) { if (twitterAccounts[i].name.equals(networkUserName)) { account.put("userName", twitterAccounts[i].name); final Account twitterAccount = twitterAccounts[i]; accountManager.getAuthToken(twitterAccount, "com.twitter.android.oauth.token", null, false, new AccountManagerCallback<Bundle>() { @Override public void run(AccountManagerFuture<Bundle> accountManagerFuture) { try { Bundle bundle = accountManagerFuture.getResult(); if (bundle.containsKey(AccountManager.KEY_INTENT)) { Intent intent = bundle .getParcelable(AccountManager.KEY_INTENT); //clear the new task flag just in case, since a result is expected int flags = intent.getFlags(); flags &= ~Intent.FLAG_ACTIVITY_NEW_TASK; intent.setFlags(flags); requestedTwitterAccountName = networkUserName; cordova.getActivity().startActivityForResult(intent, TWITTER_OAUTH_REQUEST); } else { account.put("oauth_token", bundle.getString(AccountManager.KEY_AUTHTOKEN)); accountManager.getAuthToken(twitterAccount, "com.twitter.android.oauth.token.secret", null, false, new AccountManagerCallback<Bundle>() { @Override public void run( AccountManagerFuture<Bundle> accountManagerFuture) { try { Bundle bundle = accountManagerFuture .getResult(); if (bundle.containsKey( AccountManager.KEY_INTENT)) { Intent intent = bundle .getParcelable( AccountManager.KEY_INTENT); //clear the new task flag just in case, since a result is expected int flags = intent.getFlags(); flags &= ~Intent.FLAG_ACTIVITY_NEW_TASK; intent.setFlags(flags); requestedTwitterAccountName = networkUserName; cordova.getActivity() .startActivityForResult( intent, TWITTER_OAUTH_REQUEST); } else { account.put("oauth_token_secret", bundle.getString( AccountManager.KEY_AUTHTOKEN)); json.put("data", account); Log.v(TAG, "Account data: " + json.toString()); PluginResult pluginResult = new PluginResult( PluginResult.Status.OK, json); pluginResult.setKeepCallback(true); callbackContext.sendPluginResult( pluginResult); } } catch (Exception e) { PluginResult pluginResult = new PluginResult( PluginResult.Status.ERROR, e.getLocalizedMessage()); pluginResult.setKeepCallback(true); callbackContext .sendPluginResult(pluginResult); } } }, null); } } catch (Exception e) { PluginResult pluginResult = new PluginResult( PluginResult.Status.ERROR, e.getLocalizedMessage()); pluginResult.setKeepCallback(true); callbackContext.sendPluginResult(pluginResult); } } }, null); } } } else { json.put("code", "0"); json.put("message", "no have twitter accounts"); pluginResult = new PluginResult(PluginResult.Status.ERROR, json); pluginResult.setKeepCallback(true); callbackContext.sendPluginResult(pluginResult); } } catch (JSONException e) { pluginResult = new PluginResult(PluginResult.Status.ERROR, e.getLocalizedMessage()); pluginResult.setKeepCallback(true); callbackContext.sendPluginResult(pluginResult); } } }); }
From source file:com.markupartist.sthlmtraveling.RouteDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.route_details_list); registerScreen("Route details"); Bundle extras = getIntent().getExtras(); mTrip = (Trip2) getLastNonConfigurationInstance(); if (mTrip == null) { mTrip = extras.getParcelable(EXTRA_JOURNEY_TRIP); }//from w w w. j ava 2 s.com mJourneyQuery = extras.getParcelable(EXTRA_JOURNEY_QUERY); mActionBar = initActionBar(); updateStartAndEndPointViews(mJourneyQuery); View headerView = getLayoutInflater().inflate(R.layout.route_header_details, null); TextView timeView = (TextView) headerView.findViewById(R.id.route_date_time); timeView.setText(getString(R.string.time_to, mTrip.getDurationText(), mTrip.destination.getCleanName())); if (mTrip.canBuySmsTicket()) { View buySmsTicketView = headerView.findViewById(R.id.route_buy_ticket); buySmsTicketView.setVisibility(View.VISIBLE); buySmsTicketView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Analytics.getInstance(RouteDetailActivity.this).event("Ticket", "Click on zone"); showDialog(DIALOG_BUY_SMS_TICKET); } }); TextView zoneView = (TextView) headerView.findViewById(R.id.route_zones); zoneView.setText(mTrip.tariffZones); } getListView().addHeaderView(headerView, null, false); onRouteDetailsResult(mTrip); }
From source file:com.google.sample.beaconservice.ManageBeaconFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle b = this.getArguments(); beacon = b.getParcelable("beacon"); String accountName = b.getString("accountName"); client = new ProximityBeaconImpl(getActivity(), accountName); }
From source file:com.android.server.telecom.testapps.TestConnectionService.java
@Override public Connection onCreateIncomingConnection(PhoneAccountHandle connectionManagerAccount, final ConnectionRequest request) { PhoneAccountHandle accountHandle = request.getAccountHandle(); ComponentName componentName = new ComponentName(this, TestConnectionService.class); if (accountHandle != null && componentName.equals(accountHandle.getComponentName())) { final TestConnection connection = new TestConnection(true); // Get the stashed intent extra that determines if this is a video call or audio call. Bundle extras = request.getExtras(); boolean isVideoCall = extras.getBoolean(EXTRA_IS_VIDEO_CALL); Uri providedHandle = extras.getParcelable(EXTRA_HANDLE); // Use dummy number for testing incoming calls. Uri address = providedHandle == null ? Uri.fromParts(PhoneAccount.SCHEME_TEL, getDummyNumber(isVideoCall), null) : providedHandle;/*w ww . ja v a 2s . c om*/ int videoState = isVideoCall ? VideoProfile.STATE_BIDIRECTIONAL : VideoProfile.STATE_AUDIO_ONLY; connection.setVideoState(videoState); setAddress(connection, address); addVideoProvider(connection); addCall(connection); ConnectionRequest newRequest = new ConnectionRequest(request.getAccountHandle(), address, request.getExtras(), videoState); connection.setVideoState(videoState); return connection; } else { return Connection.createFailedConnection(new DisconnectCause(DisconnectCause.ERROR, "Invalid inputs: " + accountHandle + " " + componentName)); } }
From source file:com.appeaser.sublimenavigationviewlibrary.SublimeNavigationView.java
@Override protected void onRestoreInstanceState(Parcelable savedState) { SublimeNavigationView.SavedState state = (SublimeNavigationView.SavedState) savedState; super.onRestoreInstanceState(state.getSuperState()); Bundle menuState = state.getMenuState(); if (menuState != null && menuState.containsKey(SS_MENU)) { mMenu = menuState.getParcelable(SS_MENU); }/* w w w .j a v a 2s . c o m*/ if (mMenu != null) { mMenu.setCallback(new SublimeMenu.Callback() { public boolean onMenuItemSelected(SublimeMenu menu, SublimeBaseMenuItem item, OnNavigationMenuEventListener.Event event) { return SublimeNavigationView.this.mEventListener != null && SublimeNavigationView.this.mEventListener.onNavigationMenuEvent(event, item); } }); mMenu.setMenuPresenter(getContext(), mPresenter); } }
From source file:com.android.deskclock.RingtonePickerDialogFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Restore saved instance state. if (savedInstanceState != null) { mRequestingPermission = savedInstanceState.getBoolean(STATE_KEY_REQUESTING_PERMISSION); mSelectedRingtoneUri = savedInstanceState.getParcelable(STATE_KEY_SELECTED_RINGTONE_URI); } else {// ww w. j a v a 2 s . c o m // Initialize selection to the existing ringtone. mSelectedRingtoneUri = getArguments().getParcelable(ARGS_KEY_EXISTING_RINGTONE_URI); } }
From source file:com.dan.wizardduel.MainActivity.java
@Override public void onActivityResult(int request, int response, Intent data) { super.onActivityResult(request, response, data); Log.e("tag", "activity result: " + request + " , " + response); if (request == RC_INVITATION_INBOX) { if (response != Activity.RESULT_OK) { mMainMenuFragment.stopLoading(); return; }//from ww w. j a v a2s .c o m // get the selected invitation Bundle extras = data.getExtras(); Invitation invitation = extras.getParcelable(GamesClient.EXTRA_INVITATION); // accept it! RoomConfig roomConfig = makeBasicRoomConfigBuilder() .setInvitationIdToAccept(invitation.getInvitationId()).build(); getGamesClient().joinRoom(roomConfig); // prevent screen from sleeping during handshake getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // go to game screen } else if (request == RC_SELECT_PLAYERS) { if (response != Activity.RESULT_OK) { mMainMenuFragment.stopLoading(); return; } // get the invitee list Bundle extras = data.getExtras(); final ArrayList<String> invitees = data.getStringArrayListExtra(GamesClient.EXTRA_PLAYERS); // get automatch criteria Bundle autoMatchCriteria = null; int minAutoMatchPlayers = data.getIntExtra(GamesClient.EXTRA_MIN_AUTOMATCH_PLAYERS, 0); int maxAutoMatchPlayers = data.getIntExtra(GamesClient.EXTRA_MAX_AUTOMATCH_PLAYERS, 0); if (minAutoMatchPlayers > 0) { autoMatchCriteria = RoomConfig.createAutoMatchCriteria(1, 1, 0);//minAutoMatchPlayers, maxAutoMatchPlayers, 0); } else { autoMatchCriteria = null; } // create the room and specify a variant if appropriate RoomConfig.Builder roomConfigBuilder = makeBasicRoomConfigBuilder(); roomConfigBuilder.addPlayersToInvite(invitees); if (autoMatchCriteria != null) { roomConfigBuilder.setAutoMatchCriteria(autoMatchCriteria); } RoomConfig roomConfig = roomConfigBuilder.build(); getGamesClient().createRoom(roomConfig); // prevent screen from sleeping during handshake getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } else if (request == RC_WAITING_ROOM) { if (response != Activity.RESULT_OK) { mMainMenuFragment.stopLoading(); return; } } else if (request == RC_LEADERBOARD) { mMainMenuFragment.stopLoading(); } }