List of usage examples for android.os Bundle putBundle
public void putBundle(@Nullable String key, @Nullable Bundle value)
From source file:androidx.media.MediaSession2StubImplBase.java
void notifyPlaylistChanged(final List<MediaItem2> playlist, final MediaMetadata2 metadata) { notifyAll(COMMAND_CODE_PLAYLIST_GET_LIST, new Session2Runnable() { @Override//from w w w. j a v a2s. c o m public void run(ControllerInfo controller) throws RemoteException { Bundle bundle = new Bundle(); bundle.putParcelableArray(ARGUMENT_PLAYLIST, MediaUtils2.toMediaItem2ParcelableArray(playlist)); bundle.putBundle(ARGUMENT_PLAYLIST_METADATA, metadata == null ? null : metadata.toBundle()); controller.getControllerBinder().onEvent(SESSION_EVENT_ON_PLAYLIST_CHANGED, bundle); } }); }
From source file:com.ruesga.rview.drawer.DrawerNavigationMenuPresenter.java
@Override public Parcelable onSaveInstanceState() { final Bundle state = new Bundle(); if (mMenuView != null) { SparseArray<Parcelable> hierarchy = new SparseArray<>(); mMenuView.saveHierarchyState(hierarchy); state.putSparseParcelableArray(STATE_HIERARCHY, hierarchy); }//from w ww . j av a 2s .com if (mAdapter != null) { state.putBundle(STATE_ADAPTER, mAdapter.createInstanceState()); } if (mHeaderLayout != null) { SparseArray<Parcelable> header = new SparseArray<>(); mHeaderLayout.saveHierarchyState(header); state.putSparseParcelableArray(STATE_HEADER, header); } return state; }
From source file:android.support.v7.preference.PreferenceController.java
@Override protected void onSaveViewState(@NonNull View view, @NonNull Bundle outState) { super.onSaveViewState(view, outState); final PreferenceScreen preferenceScreen = getPreferenceScreen(); if (preferenceScreen != null) { Bundle container = new Bundle(); preferenceScreen.saveHierarchyState(container); outState.putBundle(PREFERENCES_TAG, container); }/*from w w w .j av a2s. com*/ }
From source file:de.mrapp.android.dialog.example.PreferenceFragment.java
@Override public final void onSaveInstanceState(final Bundle outState) { super.onSaveInstanceState(outState); outState.putBundle(ALERT_DIALOG_STATE_EXTRA, alertDialog.onSaveInstanceState()); outState.putBundle(LIST_DIALOG_STATE_EXTRA, listDialog.onSaveInstanceState()); outState.putBundle(SINGLE_CHOICE_LIST_DIALOG_STATE_EXTRA, singleChoiceListDialog.onSaveInstanceState()); outState.putBundle(MULTIPLE_CHOICE_LIST_DIALOG_STATE_EXTRA, multipleChoiceListDialog.onSaveInstanceState()); outState.putBundle(CUSTOM_DIALOG_STATE_EXTRA, customDialog.onSaveInstanceState()); outState.putBundle(PROGRESS_DIALOG_STATE_EXTRA, progressDialog.onSaveInstanceState()); }
From source file:rikka.materialpreference.PreferenceFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); final PreferenceScreen preferenceScreen = getPreferenceScreen(); if (preferenceScreen != null) { Bundle container = new Bundle(); preferenceScreen.saveHierarchyState(container); outState.putBundle(PREFERENCES_TAG, container); }//from www . j a v a 2 s . c o m if (getListView() != null && getListView().getLayoutManager() != null && getListView().getLayoutManager() instanceof LinearLayoutManager) { LinearLayoutManager lm = ((LinearLayoutManager) getListView().getLayoutManager()); outState.putInt(SCROLL_TO_ITEM_POSITION_TAG, (lm.findFirstCompletelyVisibleItemPosition() + lm.findFirstCompletelyVisibleItemPosition()) / 2); } }
From source file:android.support.v14.preference.PreferenceFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); final PreferenceScreen preferenceScreen = getPreferenceScreen(); if (preferenceScreen != null) { Bundle container = new Bundle(); preferenceScreen.saveHierarchyState(container); outState.putBundle(PREFERENCES_TAG, container); }/*from w ww .j av a 2s .com*/ }
From source file:androidx.navigation.NavController.java
/** * Saves all navigation controller state to a Bundle. * * <p>State may be restored from a bundle returned from this method by calling * {@link #restoreState(Bundle)}. Saving controller state is the responsibility * of a {@link NavHost}.</p>/*from w w w. ja va2 s.co m*/ * * @return saved state for this controller */ @Nullable public Bundle saveState() { Bundle b = null; if (mGraphId != 0) { b = new Bundle(); b.putInt(KEY_GRAPH_ID, mGraphId); } ArrayList<String> navigatorNames = new ArrayList<>(); Bundle navigatorState = new Bundle(); for (Map.Entry<String, Navigator<? extends NavDestination>> entry : mNavigatorProvider.getNavigators() .entrySet()) { String name = entry.getKey(); Bundle savedState = entry.getValue().onSaveState(); if (savedState != null) { navigatorNames.add(name); navigatorState.putBundle(name, entry.getValue().onSaveState()); } } if (!navigatorNames.isEmpty()) { if (b == null) { b = new Bundle(); } navigatorState.putStringArrayList(KEY_NAVIGATOR_STATE_NAMES, navigatorNames); b.putBundle(KEY_NAVIGATOR_STATE, navigatorState); } if (!mBackStack.isEmpty()) { if (b == null) { b = new Bundle(); } int[] backStack = new int[mBackStack.size()]; int index = 0; for (NavDestination destination : mBackStack) { backStack[index++] = destination.getId(); } b.putIntArray(KEY_BACK_STACK_IDS, backStack); } return b; }
From source file:com.tassadar.multirommgr.installfragment.InstallCard.java
@Override public void onClick(View view) { switch (view.getId()) { case R.id.install_btn: { Bundle extras = new Bundle(); Bundle bundle = new Bundle(); bundle.putString("installation_type", "multirom"); CheckBox b = (CheckBox) m_view.findViewById(R.id.install_multirom); bundle.putBoolean("install_multirom", b.isChecked()); b = (CheckBox) m_view.findViewById(R.id.install_recovery); bundle.putBoolean("install_recovery", b.isChecked()); b = (CheckBox) m_view.findViewById(R.id.install_kernel); bundle.putBoolean("install_kernel", b.isChecked()); if (b.isChecked()) { Spinner s = (Spinner) m_view.findViewById(R.id.kernel_options); String name = (String) s.getAdapter().getItem(s.getSelectedItemPosition()); bundle.putString("kernel_name", name); }/*from ww w . j a v a2 s. co m*/ extras.putBundle("installation_info", bundle); m_listener.startActivity(extras, MainActivity.ACT_INSTALL_MULTIROM, InstallActivity.class); break; } case R.id.changelog_btn: { Changelog[] logs = m_manifest.getChangelogs(); String[] names = new String[logs.length]; String[] urls = new String[logs.length]; for (int i = 0; i < logs.length; ++i) { names[i] = logs[i].name; urls[i] = logs[i].url; } Bundle b = new Bundle(); b.putStringArray("changelog_names", names); b.putStringArray("changelog_urls", urls); m_listener.startActivity(b, MainActivity.ACT_CHANGELOG, ChangelogActivity.class); break; } } }
From source file:com.karura.framework.PluginManager.java
/** * The main activity has been asked to store instance data as the system is about to kill the activity. * //from w ww . j a v a 2 s . c o m * We ask all plugins if they have any instance data that they would like to persist across the lifetime * * @param saveBundle * The bundle instance in which plugin data needs to be persisted */ public void onSaveInstanceState(Bundle saveBundle) { Bundle pluginManagerBundle = new Bundle(); for (WebViewPlugin plugin : instanceMap.values()) { // We are storing each plugin data in an individual bundle Bundle pluginInstanceData = new Bundle(); plugin.onSaveInstanceState(pluginInstanceData); // add our meta data information to the bundle // this will help us recreate these bundles later pluginInstanceData.putString(PLUGIN_CLASS_NAME_KEY, plugin.getClass().getName()); pluginInstanceData.putString(PLUGIN_ID_KEY, plugin.getId()); // persist the bundles pluginManagerBundle.putBundle(PLUGIN_INSTANCE_DATA_KEY_PREFIX + plugin.getId(), pluginInstanceData); } saveBundle.putBundle(PLUGIN_MGR_INSTANCE_DATA_KEY, pluginManagerBundle); // release any memory associated with the plugins // TODO figure out what we should do with the messages which the plugins have scheduled // on the javascript library, for now we are releasing everything, assuming webview // associated with the plugin manager has been stopped as well, and it might not be // able execute any of the scheduled requests releasePlugins(); }
From source file:bolts.AppLinkTest.java
public void testAppLinkNavInEventBroadcast() throws Exception { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com")); Bundle appLinkData = new Bundle(); appLinkData.putString("target_url", "http://www.example2.com"); Bundle appLinkRefererData = new Bundle(); appLinkRefererData.putString("url", "referer://"); appLinkRefererData.putString("app_name", "Referrer App"); appLinkRefererData.putString("package", "com.bolts.referrer"); appLinkData.putBundle("referer_app_link", appLinkRefererData); Bundle applinkExtras = new Bundle(); applinkExtras.putString("token", "a_token"); appLinkData.putBundle("extras", applinkExtras); i.putExtra("al_applink_data", appLinkData); final CountDownLatch lock = new CountDownLatch(1); final String[] receivedStrings = new String[7]; LocalBroadcastManager manager = LocalBroadcastManager.getInstance(getInstrumentation().getTargetContext()); manager.registerReceiver(new BroadcastReceiver() { @Override//from www . ja v a 2 s . c om public void onReceive(Context context, Intent intent) { String eventName = intent.getStringExtra("event_name"); Bundle eventArgs = intent.getBundleExtra("event_args"); receivedStrings[0] = eventName; receivedStrings[1] = eventArgs.getString("targetURL"); receivedStrings[2] = eventArgs.getString("inputURL"); receivedStrings[3] = eventArgs.getString("refererURL"); receivedStrings[4] = eventArgs.getString("refererAppName"); receivedStrings[5] = eventArgs.getString("extras/token"); receivedStrings[6] = eventArgs.getString("sourceApplication"); lock.countDown(); } }, new IntentFilter("com.parse.bolts.measurement_event")); Uri targetUrl = AppLinks.getTargetUrlFromInboundIntent(getInstrumentation().getTargetContext(), i); lock.await(2000, TimeUnit.MILLISECONDS); assertEquals("al_nav_in", receivedStrings[0]); assertEquals("http://www.example2.com", receivedStrings[1]); assertEquals("http://www.example.com", receivedStrings[2]); assertEquals("referer://", receivedStrings[3]); assertEquals("Referrer App", receivedStrings[4]); assertEquals("a_token", receivedStrings[5]); assertEquals("com.bolts.referrer", receivedStrings[6]); }