List of usage examples for android.os Bundle putParcelable
public void putParcelable(@Nullable String key, @Nullable Parcelable value)
From source file:android.support.v7.widget.SearchView.java
/** * Create and return an Intent that can launch the voice search activity, perform a specific * voice transcription, and forward the results to the searchable activity. * * @param baseIntent The voice app search intent to start from * @return A completely-configured intent ready to send to the voice search activity *//*from ww w . j a va 2 s . c o m*/ @TargetApi(Build.VERSION_CODES.FROYO) private Intent createVoiceAppSearchIntent(Intent baseIntent, SearchableInfo searchable) { ComponentName searchActivity = searchable.getSearchActivity(); // create the necessary intent to set up a search-and-forward operation // in the voice search system. We have to keep the bundle separate, // because it becomes immutable once it enters the PendingIntent Intent queryIntent = new Intent(Intent.ACTION_SEARCH); queryIntent.setComponent(searchActivity); PendingIntent pending = PendingIntent.getActivity(getContext(), 0, queryIntent, PendingIntent.FLAG_ONE_SHOT); // Now set up the bundle that will be inserted into the pending intent // when it's time to do the search. We always build it here (even if empty) // because the voice search activity will always need to insert "QUERY" into // it anyway. Bundle queryExtras = new Bundle(); if (mAppSearchData != null) { queryExtras.putParcelable(SearchManager.APP_DATA, mAppSearchData); } // Now build the intent to launch the voice search. Add all necessary // extras to launch the voice recognizer, and then all the necessary extras // to forward the results to the searchable activity Intent voiceIntent = new Intent(baseIntent); // Add all of the configuration options supplied by the searchable's metadata String languageModel = RecognizerIntent.LANGUAGE_MODEL_FREE_FORM; String prompt = null; String language = null; int maxResults = 1; if (Build.VERSION.SDK_INT >= 8) { Resources resources = getResources(); if (searchable.getVoiceLanguageModeId() != 0) { languageModel = resources.getString(searchable.getVoiceLanguageModeId()); } if (searchable.getVoicePromptTextId() != 0) { prompt = resources.getString(searchable.getVoicePromptTextId()); } if (searchable.getVoiceLanguageId() != 0) { language = resources.getString(searchable.getVoiceLanguageId()); } if (searchable.getVoiceMaxResults() != 0) { maxResults = searchable.getVoiceMaxResults(); } } voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel); voiceIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt); voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language); voiceIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxResults); voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, searchActivity == null ? null : searchActivity.flattenToShortString()); // Add the values that configure forwarding the results voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, pending); voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT_BUNDLE, queryExtras); return voiceIntent; }
From source file:com.apptentive.android.sdk.module.engagement.interaction.fragment.MessageCenterFragment.java
@Override public void onSaveInstanceState(Bundle outState) { savePendingComposingMessage();/*from ww w. j ava 2s . c o m*/ //int index = messageCenterRecyclerView.getFirstVisiblePosition(); View v = messageCenterRecyclerView.getChildAt(0); int top = (v == null) ? 0 : (v.getTop() - messageCenterRecyclerView.getPaddingTop()); outState.putInt(LIST_TOP_OFFSET, top); outState.putParcelable(COMPOSING_EDITTEXT_STATE, saveEditTextInstanceState()); if (messageCenterRecyclerViewAdapter != null) { outState.putParcelable(WHO_CARD_NAME, whoCardNameEditText != null ? whoCardNameEditText.onSaveInstanceState() : null); outState.putParcelable(WHO_CARD_EMAIL, whoCardEmailEditText != null ? whoCardEmailEditText.onSaveInstanceState() : null); outState.putString(WHO_CARD_AVATAR_FILE, messageCenterRecyclerViewAdapter.getWhoCardAvatarFileName()); } outState.putBoolean(WHO_CARD_MODE, pendingWhoCardMode); super.onSaveInstanceState(outState); }
From source file:com.android.settings.Settings.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); // Save the current fragment, if it is the same as originally launched if (mCurrentHeader != null) { outState.putParcelable(SAVE_KEY_CURRENT_HEADER, mCurrentHeader); }/*from w w w .j a v a 2 s . c o m*/ if (mParentHeader != null) { outState.putParcelable(SAVE_KEY_PARENT_HEADER, mParentHeader); } }
From source file:com.dwdesign.tweetings.fragment.UserProfileFragment.java
@Override public boolean onMenuItemClick(final MenuItem item) { if (mUser == null || mService == null) return false; switch (item.getItemId()) { case MENU_TAKE_PHOTO: { takePhoto();/*from w w w .j av a 2 s.com*/ break; } case MENU_ADD_IMAGE: { pickImage(); break; } case MENU_BANNER_TAKE_PHOTO: { takeBannerPhoto(); break; } case MENU_BANNER_ADD_IMAGE: { pickBannerImage(); break; } case MENU_TRACKING: { UpdateTrackingTask task = new UpdateTrackingTask(!tracking); task.execute(); break; } case MENU_BLOCK: { if (mService == null || mFriendship == null) { break; } if (mFriendship.isSourceBlockingTarget()) { mService.destroyBlock(mAccountId, mUser.getId()); } else { mService.createBlock(mAccountId, mUser.getId()); } break; } case MENU_REPORT_SPAM: { mService.reportSpam(mAccountId, mUser.getId()); break; } case MENU_MUTE_USER: { final String screen_name = mUser.getScreenName(); final Uri uri = Filters.Users.CONTENT_URI; final ContentValues values = new ContentValues(); final SharedPreferences.Editor editor = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE).edit(); final ContentResolver resolver = getContentResolver(); values.put(Filters.Users.TEXT, screen_name); resolver.delete(uri, Filters.Users.TEXT + " = '" + screen_name + "'", null); resolver.insert(uri, values); editor.putBoolean(PREFERENCE_KEY_ENABLE_FILTER, true).commit(); Toast.makeText(getActivity(), R.string.user_muted, Toast.LENGTH_SHORT).show(); break; } case MENU_MENTION: { final Intent intent = new Intent(INTENT_ACTION_COMPOSE); final Bundle bundle = new Bundle(); final String name = mUser.getName(); final String screen_name = mUser.getScreenName(); bundle.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId); bundle.putString(INTENT_KEY_TEXT, "@" + screen_name + " "); bundle.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, screen_name); bundle.putString(INTENT_KEY_IN_REPLY_TO_NAME, name); intent.putExtras(bundle); startActivity(intent); break; } case MENU_SEND_DIRECT_MESSAGE: { final Uri.Builder builder = new Uri.Builder(); builder.scheme(SCHEME_TWEETINGS); builder.authority(AUTHORITY_DIRECT_MESSAGES_CONVERSATION); builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(mAccountId)); builder.appendQueryParameter(QUERY_PARAM_CONVERSATION_ID, String.valueOf(mUser.getId())); startActivity(new Intent(Intent.ACTION_VIEW, builder.build())); break; } case MENU_VIEW_ON_TWITTER: { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://twitter.com/" + mUser.getScreenName())); startActivity(browserIntent); break; } case MENU_WANT_RETWEETS: { updateFriendship(); break; } case MENU_EXTENSIONS: { final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER); final Bundle extras = new Bundle(); extras.putParcelable(INTENT_KEY_USER, new ParcelableUser(mUser, mAccountId)); intent.putExtras(extras); startActivity(Intent.createChooser(intent, getString(R.string.open_with_extensions))); break; } case MENU_SET_COLOR: { final Intent intent = new Intent(INTENT_ACTION_SET_COLOR); startActivityForResult(intent, REQUEST_SET_COLOR); break; } case MENU_CLEAR_COLOR: { clearUserColor(getActivity(), mUserId); updateUserColor(); break; } } return true; }
From source file:com.owncloud.android.ui.activity.FileDisplayActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { // responsibility of restore is preferred in onCreate() before than in // onRestoreInstanceState when there are Fragments involved Log_OC.e(TAG, "onSaveInstanceState() start"); super.onSaveInstanceState(outState); outState.putParcelable(FileDisplayActivity.KEY_WAITING_TO_PREVIEW, mWaitingToPreview); Log_OC.d(TAG, "onSaveInstanceState() end"); }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
/** * @param testPoint //from w w w . j a v a 2 s . co m * @param mapType * */ public RMBTMapFragment showMap(String mapType, LatLng initialCenter, boolean clearFilter, int viewId, boolean popBackStack) { if (popBackStack) { popBackStackFull(); } FragmentTransaction ft; setCurrentMapType(mapType); if (clearFilter) { final List<MapListSection> mapFilterListSelectionList = getMapFilterListSelectionList(); if (mapFilterListSelectionList != null) { for (final MapListSection section : mapFilterListSelectionList) { for (final MapListEntry entry : section.getMapListEntryList()) entry.setChecked(entry.isDefault()); } updateMapFilter(); } } final RMBTMapFragment fragment = new RMBTMapFragment(); final Bundle bundle = new Bundle(); bundle.putParcelable("initialCenter", initialCenter); if (viewId >= 0) { bundle.putBoolean(RMBTMapFragment.OPTION_ENABLE_ALL_GESTURES, false); bundle.putBoolean(RMBTMapFragment.OPTION_SHOW_INFO_TOAST, false); bundle.putBoolean(RMBTMapFragment.OPTION_ENABLE_CONTROL_BUTTONS, false); bundle.putBoolean(RMBTMapFragment.OPTION_ENABLE_OVERLAY, false); fragment.setArguments(bundle); ft = fm.beginTransaction(); //replace the given viewgroup, but do not add to backstack ft.replace(viewId, fragment, AppConstants.PAGE_TITLE_MINI_MAP); //ft.addToBackStack(AppConstants.PAGE_TITLE_MINI_MAP); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commit(); } else { System.out.println("SHOW MAP"); fragment.setArguments(bundle); ft = fm.beginTransaction(); ft.replace(R.id.fragment_content, fragment, AppConstants.PAGE_TITLE_MAP); ft.addToBackStack(AppConstants.PAGE_TITLE_MAP); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commit(); refreshActionBar(AppConstants.PAGE_TITLE_MAP); } return fragment; }
From source file:com.andrewshu.android.reddit.profile.ProfileActivity.java
@Override protected void onSaveInstanceState(Bundle state) { super.onSaveInstanceState(state); state.putString(Constants.USERNAME_KEY, mUsername); state.putString(Constants.CommentsSort.SORT_BY_KEY, mSortByUrl); state.putString(Constants.JUMP_TO_THREAD_ID_KEY, mJumpToThreadId); state.putString(Constants.AFTER_KEY, mAfter); state.putString(Constants.BEFORE_KEY, mBefore); state.putInt(Constants.THREAD_COUNT_KEY, mCount); state.putString(Constants.LAST_AFTER_KEY, mLastAfter); state.putString(Constants.LAST_BEFORE_KEY, mLastBefore); state.putInt(Constants.THREAD_LAST_COUNT_KEY, mLastCount); state.putStringArray(Constants.KARMA_KEY, mKarma); state.putParcelable(Constants.VOTE_TARGET_THING_INFO_KEY, mVoteTargetThingInfo); }
From source file:com.andrewshu.android.reddit.user.ProfileActivity.java
@Override protected void onSaveInstanceState(Bundle state) { super.onSaveInstanceState(state); state.putString(Constants.USERNAME_KEY, mUsername); state.putString(Constants.CommentsSort.SORT_BY_KEY, mSortByUrl); state.putString(Constants.JUMP_TO_THREAD_ID_KEY, mJumpToThreadId); state.putString(Constants.AFTER_KEY, mAfter); state.putString(Constants.BEFORE_KEY, mBefore); state.putInt(Constants.THREAD_COUNT_KEY, mCount); state.putString(Constants.LAST_AFTER_KEY, mLastAfter); state.putString(Constants.LAST_BEFORE_KEY, mLastBefore); state.putInt(Constants.THREAD_LAST_COUNT_KEY, mLastCount); state.putIntArray(Constants.KARMA_KEY, mKarma); state.putParcelable(Constants.VOTE_TARGET_THING_INFO_KEY, mVoteTargetThingInfo); }
From source file:com.cerema.cloud2.ui.activity.FileDisplayActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { // responsibility of restore is preferred in onCreate() before than in // onRestoreInstanceState when there are Fragments involved Log_OC.v(TAG, "onSaveInstanceState() start"); super.onSaveInstanceState(outState); outState.putParcelable(FileDisplayActivity.KEY_WAITING_TO_PREVIEW, mWaitingToPreview); outState.putBoolean(FileDisplayActivity.KEY_SYNC_IN_PROGRESS, mSyncInProgress); //outState.putBoolean(FileDisplayActivity.KEY_REFRESH_SHARES_IN_PROGRESS, // mRefreshSharesInProgress); outState.putParcelable(FileDisplayActivity.KEY_WAITING_TO_SEND, mWaitingToSend); Log_OC.v(TAG, "onSaveInstanceState() end"); }
From source file:com.android.deskclock.AlarmClockFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putLong(KEY_EXPANDED_ID, mAdapter.getExpandedId()); outState.putLongArray(KEY_REPEAT_CHECKED_IDS, mAdapter.getRepeatArray()); outState.putLongArray(KEY_SELECTED_ALARMS, mAdapter.getSelectedAlarmsArray()); outState.putBundle(KEY_RINGTONE_TITLE_CACHE, mRingtoneTitleCache); outState.putParcelable(KEY_DELETED_ALARM, mDeletedAlarm); outState.putBoolean(KEY_UNDO_SHOWING, mUndoShowing); outState.putBundle(KEY_PREVIOUS_DAY_MAP, mAdapter.getPreviousDaysOfWeekMap()); outState.putParcelable(KEY_SELECTED_ALARM, mSelectedAlarm); }