List of usage examples for android.os Bundle getBundle
@Nullable
public Bundle getBundle(@Nullable String key)
From source file:com.android.cts.verifier.managedprovisioning.ByodHelperActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { Log.w(TAG, "Restored state"); mOriginalSettings = savedInstanceState.getBundle(ORIGINAL_SETTINGS_NAME); } else {//www . j a v a2 s . c o m mOriginalSettings = new Bundle(); } mAdminReceiverComponent = new ComponentName(this, DeviceAdminTestReceiver.class.getName()); mDevicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Intent intent = getIntent(); String action = intent.getAction(); Log.d(TAG, "ByodHelperActivity.onCreate: " + action); // we are explicitly started by {@link DeviceAdminTestReceiver} after a successful provisioning. if (action.equals(ACTION_PROFILE_PROVISIONED)) { // Jump back to CTS verifier with result. Intent response = new Intent(ACTION_PROFILE_OWNER_STATUS); response.putExtra(EXTRA_PROVISIONED, isProfileOwner()); startActivityInPrimary(response); // Queried by CtsVerifier in the primary side using startActivityForResult. } else if (action.equals(ACTION_QUERY_PROFILE_OWNER)) { Intent response = new Intent(); response.putExtra(EXTRA_PROVISIONED, isProfileOwner()); setResult(RESULT_OK, response); // Request to delete work profile. } else if (action.equals(ACTION_REMOVE_MANAGED_PROFILE)) { if (isProfileOwner()) { Log.d(TAG, "Clearing cross profile intents"); mDevicePolicyManager.clearCrossProfileIntentFilters(mAdminReceiverComponent); mDevicePolicyManager.wipeData(0); showToast(R.string.provisioning_byod_profile_deleted); } } else if (action.equals(ACTION_INSTALL_APK)) { boolean allowNonMarket = intent.getBooleanExtra(EXTRA_ALLOW_NON_MARKET_APPS, false); boolean wasAllowed = getAllowNonMarket(); // Update permission to install non-market apps setAllowNonMarket(allowNonMarket); mOriginalSettings.putBoolean(INSTALL_NON_MARKET_APPS, wasAllowed); // Request to install a non-market application- easiest way is to reinstall ourself final Intent installIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE) .setData(Uri.parse("package:" + getPackageName())) .putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true).putExtra(Intent.EXTRA_RETURN_RESULT, true); startActivityForResult(installIntent, REQUEST_INSTALL_PACKAGE); // Not yet ready to finish- wait until the result comes back return; // Queried by CtsVerifier in the primary side using startActivityForResult. } else if (action.equals(ACTION_CHECK_INTENT_FILTERS)) { final boolean intentFiltersSetForManagedIntents = new IntentFiltersTestHelper(this) .checkCrossProfileIntentFilters(IntentFiltersTestHelper.FLAG_INTENTS_FROM_MANAGED); setResult(intentFiltersSetForManagedIntents ? RESULT_OK : RESULT_FAILED, null); } else if (action.equals(ACTION_CAPTURE_AND_CHECK_IMAGE)) { // We need the camera permission to send the image capture intent. grantCameraPermissionToSelf(); Intent captureImageIntent = getCaptureImageIntent(); Pair<File, Uri> pair = getTempUri("image.jpg"); mImageFile = pair.first; mImageUri = pair.second; captureImageIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri); if (captureImageIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(captureImageIntent, REQUEST_IMAGE_CAPTURE); } else { Log.e(TAG, "Capture image intent could not be resolved in managed profile."); showToast(R.string.provisioning_byod_capture_media_error); finish(); } return; } else if (action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT) || action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITHOUT_EXTRA_OUTPUT)) { // We need the camera permission to send the video capture intent. grantCameraPermissionToSelf(); Intent captureVideoIntent = getCaptureVideoIntent(); int videoCaptureRequestId; if (action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT)) { mVideoUri = getTempUri("video.mp4").second; captureVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, mVideoUri); videoCaptureRequestId = REQUEST_VIDEO_CAPTURE_WITH_EXTRA_OUTPUT; } else { videoCaptureRequestId = REQUEST_VIDEO_CAPTURE_WITHOUT_EXTRA_OUTPUT; } if (captureVideoIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(captureVideoIntent, videoCaptureRequestId); } else { Log.e(TAG, "Capture video intent could not be resolved in managed profile."); showToast(R.string.provisioning_byod_capture_media_error); finish(); } return; } else if (action.equals(ACTION_CAPTURE_AND_CHECK_AUDIO)) { Intent captureAudioIntent = getCaptureAudioIntent(); if (captureAudioIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(captureAudioIntent, REQUEST_AUDIO_CAPTURE); } else { Log.e(TAG, "Capture audio intent could not be resolved in managed profile."); showToast(R.string.provisioning_byod_capture_media_error); finish(); } return; } else if (ACTION_KEYGUARD_DISABLED_FEATURES.equals(action)) { final int value = intent.getIntExtra(EXTRA_PARAMETER_1, DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_NONE); mDevicePolicyManager.setKeyguardDisabledFeatures(mAdminReceiverComponent, value); } else if (ACTION_LOCKNOW.equals(action)) { mDevicePolicyManager.lockNow(); setResult(RESULT_OK); } else if (action.equals(ACTION_TEST_NFC_BEAM)) { Intent testNfcBeamIntent = new Intent(this, NfcTestActivity.class); testNfcBeamIntent.putExtras(intent); startActivity(testNfcBeamIntent); finish(); return; } else if (action.equals(ACTION_TEST_CROSS_PROFILE_INTENTS_DIALOG)) { sendIntentInsideChooser(new Intent(CrossProfileTestActivity.ACTION_CROSS_PROFILE_TO_PERSONAL)); } else if (action.equals(ACTION_TEST_APP_LINKING_DIALOG)) { mDevicePolicyManager.addUserRestriction(DeviceAdminTestReceiver.getReceiverComponentName(), UserManager.ALLOW_PARENT_PROFILE_APP_LINKING); Intent toSend = new Intent(Intent.ACTION_VIEW); toSend.setData(Uri.parse("http://com.android.cts.verifier")); sendIntentInsideChooser(toSend); } else if (action.equals(ACTION_SET_USER_RESTRICTION)) { final String restriction = intent.getStringExtra(EXTRA_PARAMETER_1); if (restriction != null) { mDevicePolicyManager.addUserRestriction(DeviceAdminTestReceiver.getReceiverComponentName(), restriction); } } else if (action.equals(ACTION_CLEAR_USER_RESTRICTION)) { final String restriction = intent.getStringExtra(EXTRA_PARAMETER_1); if (restriction != null) { mDevicePolicyManager.clearUserRestriction(DeviceAdminTestReceiver.getReceiverComponentName(), restriction); } } else if (action.equals(ACTION_BYOD_SET_LOCATION_AND_CHECK_UPDATES)) { handleLocationAction(); return; } else if (action.equals(ACTION_NOTIFICATION)) { showNotification(Notification.VISIBILITY_PUBLIC); } else if (ACTION_NOTIFICATION_ON_LOCKSCREEN.equals(action)) { mDevicePolicyManager.lockNow(); showNotification(Notification.VISIBILITY_PRIVATE); } else if (ACTION_CLEAR_NOTIFICATION.equals(action)) { mNotificationManager.cancel(NOTIFICATION_ID); } else if (ACTION_TEST_SELECT_WORK_CHALLENGE.equals(action)) { mDevicePolicyManager.setOrganizationColor(mAdminReceiverComponent, Color.BLUE); mDevicePolicyManager.setOrganizationName(mAdminReceiverComponent, getResources().getString(R.string.provisioning_byod_confirm_work_credentials_header)); startActivity(new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD)); } else if (ACTION_LAUNCH_CONFIRM_WORK_CREDENTIALS.equals(action)) { KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); Intent launchIntent = keyguardManager.createConfirmDeviceCredentialIntent(null, null); startActivity(launchIntent); } else if (ACTION_SET_ORGANIZATION_INFO.equals(action)) { if (intent.hasExtra(OrganizationInfoTestActivity.EXTRA_ORGANIZATION_NAME)) { final String organizationName = intent .getStringExtra(OrganizationInfoTestActivity.EXTRA_ORGANIZATION_NAME); mDevicePolicyManager.setOrganizationName(mAdminReceiverComponent, organizationName); } final int organizationColor = intent.getIntExtra(OrganizationInfoTestActivity.EXTRA_ORGANIZATION_COLOR, mDevicePolicyManager.getOrganizationColor(mAdminReceiverComponent)); mDevicePolicyManager.setOrganizationColor(mAdminReceiverComponent, organizationColor); } else if (ACTION_TEST_PARENT_PROFILE_PASSWORD.equals(action)) { startActivity(new Intent(DevicePolicyManager.ACTION_SET_NEW_PARENT_PROFILE_PASSWORD)); } // This activity has no UI and is only used to respond to CtsVerifier in the primary side. finish(); }
From source file:com.fastbootmobile.encore.app.ArtistActivity.java
@Override @TargetApi(Build.VERSION_CODES.LOLLIPOP) protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_artist); mHandler = new Handler(); FragmentManager fm = getSupportFragmentManager(); mActiveFragment = (ArtistFragment) fm.findFragmentByTag(TAG_FRAGMENT); if (savedInstanceState == null) { mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO); mInitialIntent = getIntent().getExtras(); } else {/* w w w .j av a 2 s. c om*/ mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO); mInitialIntent = savedInstanceState.getBundle(EXTRA_RESTORE_INTENT); } if (mActiveFragment == null) { mActiveFragment = new ArtistFragment(); fm.beginTransaction().add(R.id.container, mActiveFragment, TAG_FRAGMENT).commit(); } mActiveFragment.setArguments(mHero, mInitialIntent); // Remove the activity title as we don't want it here mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); actionBar.setTitle(""); } mIsEntering = true; if (Utils.hasLollipop()) { setEnterSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { View fab = mActiveFragment.findViewById(R.id.fabPlay); fab.setVisibility(View.VISIBLE); // get the center for the clipping circle int cx = fab.getMeasuredWidth() / 2; int cy = fab.getMeasuredHeight() / 2; // get the final radius for the clipping circle final int finalRadius = fab.getWidth(); // create and start the animator for this view // (the start radius is zero) Animator anim; if (mIsEntering) { anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, 0, finalRadius); } else { anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, finalRadius, 0); } anim.setInterpolator(new DecelerateInterpolator()); anim.start(); fab.setTranslationX(-fab.getMeasuredWidth() / 4.0f); fab.setTranslationY(-fab.getMeasuredHeight() / 4.0f); fab.animate().translationX(0.0f).translationY(0.0f) .setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime)) .setInterpolator(new DecelerateInterpolator()).start(); final View artistName = mActiveFragment.findViewById(R.id.tvArtist); if (artistName != null) { cx = artistName.getMeasuredWidth() / 4; cy = artistName.getMeasuredHeight() / 2; final int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime); final int radius = Utils.getEnclosingCircleRadius(artistName, cx, cy); if (mIsEntering) { artistName.setVisibility(View.INVISIBLE); Utils.animateCircleReveal(artistName, cx, cy, 0, radius, duration, 300); } else { artistName.setVisibility(View.VISIBLE); Utils.animateCircleReveal(artistName, cx, cy, radius, 0, duration, 0); } } } }); } getWindow().getDecorView() .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); }
From source file:com.facebook.android.FacebookClient.java
/** * Constructor.//from ww w . j a v a 2 s . co m * * @param context * The application context. * @param appId * This application's Facebook Application ID. * @since 1.0.0 */ public FacebookClient(final Context context, final Bundle savedInstanceState, final DialogListener dialogListener, final String appId) { super(appId); this.mSharedPreferences = context.getSharedPreferences("facebook", Context.MODE_PRIVATE); this.mAccessToken = this.mSharedPreferences.getString(KEY_ACCESS_TOKEN, null); this.mExpires = this.mSharedPreferences.getLong(KEY_ACCESS_EXPIRES, 0); if (this.mAccessToken != null) { setAccessToken(this.mAccessToken); } if (this.mExpires != 0) { setAccessExpires(this.mExpires); } Bundle fbdata = null; if (savedInstanceState != null && (fbdata = savedInstanceState.getBundle("facebookclient")) != null) { mAuthActivityCode = fbdata.getInt("mAuthActivityCode"); mAuthPermissions = fbdata.getStringArray("mAuthPermissions"); } mAuthDialogListener = new SaveTokenListener(dialogListener); }
From source file:com.oceansky.yellow.app.ArtistActivity.java
@Override @TargetApi(Build.VERSION_CODES.LOLLIPOP) protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_artist); mHandler = new Handler(); FragmentManager fm = getSupportFragmentManager(); mActiveFragment = (ArtistFragment) fm.findFragmentByTag(TAG_FRAGMENT); if (savedInstanceState == null) { mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO); mInitialIntent = getIntent().getExtras(); } else {/*from w ww .j a va2 s.c om*/ mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO); mInitialIntent = savedInstanceState.getBundle(EXTRA_RESTORE_INTENT); } if (mActiveFragment == null) { mActiveFragment = new ArtistFragment(); fm.beginTransaction().add(R.id.container, mActiveFragment, TAG_FRAGMENT).commit(); } try { mActiveFragment.setArguments(mHero, mInitialIntent); } catch (IllegalStateException e) { Log.e(TAG, "Invalid artist!", e); } // Remove the activity title as we don't want it here mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); actionBar.setTitle(""); } mIsEntering = true; if (Utils.hasLollipop()) { setEnterSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { View fab = mActiveFragment.findViewById(R.id.fabPlay); fab.setVisibility(View.VISIBLE); // get the center for the clipping circle int cx = fab.getMeasuredWidth() / 2; int cy = fab.getMeasuredHeight() / 2; // get the final radius for the clipping circle final int finalRadius = fab.getWidth(); // create and start the animator for this view // (the start radius is zero) Animator anim; if (mIsEntering) { anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, 0, finalRadius); } else { anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, finalRadius, 0); } anim.setInterpolator(new DecelerateInterpolator()); anim.start(); fab.setTranslationX(-fab.getMeasuredWidth() / 4.0f); fab.setTranslationY(-fab.getMeasuredHeight() / 4.0f); fab.animate().translationX(0.0f).translationY(0.0f) .setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime)) .setInterpolator(new DecelerateInterpolator()).start(); final View artistName = mActiveFragment.findViewById(R.id.tvArtist); if (artistName != null) { cx = artistName.getMeasuredWidth() / 4; cy = artistName.getMeasuredHeight() / 2; final int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime); final int radius = Utils.getEnclosingCircleRadius(artistName, cx, cy); if (mIsEntering) { artistName.setVisibility(View.INVISIBLE); Utils.animateCircleReveal(artistName, cx, cy, 0, radius, duration, 300); } else { artistName.setVisibility(View.VISIBLE); Utils.animateCircleReveal(artistName, cx, cy, radius, 0, duration, 0); } } } }); } getWindow().getDecorView() .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); }
From source file:com.github.mguidi.asyncop.AsyncOpHelper.java
/** * @param context// www. jav a 2 s.co m * @param savedInstanceState * @param callback */ public AsyncOpHelper(Context context, Bundle savedInstanceState, AsyncOpCallback callback) { mContext = context.getApplicationContext(); mAsyncOpCallback = callback; if (savedInstanceState == null) { mIdHelper = UUID.randomUUID().toString(); mNextIdRequest = 0; mPendingRequests = new ArrayList<Integer>(); mMapPendingRequestsAction = new Bundle(); } else { mIdHelper = savedInstanceState.getString(SAVED_ID_HELPER); mNextIdRequest = savedInstanceState.getInt(SAVED_ID_REQUEST); mPendingRequests = savedInstanceState.getIntegerArrayList(SAVED_PENDING_REQUESTS); mMapPendingRequestsAction = savedInstanceState.getBundle(SAVED_MAP_PENDING_REQUESTS_ACTION); } }
From source file:de.sourcestream.movieDB.controller.SearchList.java
/** * Called to do initial creation of a fragment. * This is called after onAttach(Activity) and before onCreateView(LayoutInflater, ViewGroup, Bundle). * * @param savedInstanceState If the fragment is being re-created from a previous saved state, this is the state. *//*ww w. ja v a 2 s . c o m*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) save = savedInstanceState.getBundle("save"); if (getActivity() != null) ((MainActivity) getActivity()).setSearchViewCount(true); }
From source file:com.firefly.sample.castcompanionlibrary.cast.player.VideoCastControllerFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mCastConsumer = new MyCastConsumer(); Bundle bundle = getArguments(); if (null == bundle) { return;/*from w ww . j a va 2s . c om*/ } Bundle extras = bundle.getBundle(EXTRAS); Bundle mediaWrapper = extras.getBundle(VideoCastManager.EXTRA_MEDIA); // Retain this fragment across configuration changes. setRetainInstance(true); if (extras.getBoolean(VideoCastManager.EXTRA_HAS_AUTH)) { mOverallState = OverallState.AUTHORIZING; mMediaAuthService = mCastManager.getMediaAuthService(); handleMediaAuthTask(mMediaAuthService); showImage(Utils.getImageUrl(mMediaAuthService.getMediaInfo(), 1)); } else if (null != mediaWrapper) { mOverallState = OverallState.PLAYBACK; boolean shouldStartPlayback = extras.getBoolean(VideoCastManager.EXTRA_SHOULD_START); String customDataStr = extras.getString(VideoCastManager.EXTRA_CUSTOM_DATA); JSONObject customData = null; if (!TextUtils.isEmpty(customDataStr)) { try { customData = new JSONObject(customDataStr); } catch (JSONException e) { LOGE(TAG, "Failed to unmarshalize custom data string: customData=" + customDataStr, e); } } MediaInfo info = Utils.toMediaInfo(mediaWrapper); int startPoint = extras.getInt(VideoCastManager.EXTRA_START_POINT, 0); onReady(info, shouldStartPlayback, startPoint, customData); } }
From source file:com.javielinux.tweettopics2.TweetActivity.java
@Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); // muestra la imagen si est en versiones superiores a HONEYCOMB if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (hasFocus) { Bundle extras = getIntent().getExtras(); if (extras != null) { if (extras.containsKey(Utils.KEY_EXTRAS_INFO) && extras.getBundle(Utils.KEY_EXTRAS_INFO).containsKey(KEY_EXTRAS_LINK)) { InfoLink infoLink = CacheData.getInstance().getCacheInfoLink( extras.getBundle(Utils.KEY_EXTRAS_INFO).getString(KEY_EXTRAS_LINK)); if (infoLink != null && infoLink.isExtensiveInfo() && infoLink.getType() == InfoLink.IMAGE) { showImage(infoLink); }/* www . java 2 s . co m*/ } } } } }
From source file:android.support.mediacompat.client.ClientBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { Bundle extras = intent.getExtras(); MediaControllerCompat controller;/*from w w w. j a v a 2s.com*/ 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:androidx.navigation.NavController.java
/** * Restores all navigation controller state from a bundle. * * <p>State may be saved to a bundle by calling {@link #saveState()}. * Restoring controller state is the responsibility of a {@link NavHost}.</p> * * @param navState state bundle to restore *//*from w w w . ja v a2 s.com*/ public void restoreState(@Nullable Bundle navState) { if (navState == null) { return; } mGraphId = navState.getInt(KEY_GRAPH_ID); mNavigatorStateToRestore = navState.getBundle(KEY_NAVIGATOR_STATE); mBackStackToRestore = navState.getIntArray(KEY_BACK_STACK_IDS); if (mGraphId != 0) { // Set the graph right away, onGraphCreated will handle restoring the // rest of the saved state setGraph(mGraphId); } }