public static boolean hasPosition(Bundle args) { return args != null && args.containsKey(KEY_POSITION); }
// You can be pretty confident that the intent will not be null here. Intent intent = getIntent(); // Get the extras (if there are any) Bundle extras = intent.getExtras(); if (extras != null) { if (extras.containsKey("isNewItem")) { boolean isNew = extras.getBoolean("isNewItem", false); // TODO: Do something with the value of isNew. } }
/** * Returns the gesture with which the user completed the native dialog. This is only returned * if the user has previously authorized the calling app with basic permissions. * * @param result the bundle passed back to onActivityResult * @return "post" or "cancel" as the completion gesture */ public static String getNativeDialogCompletionGesture(Bundle result) { if (result.containsKey(NativeProtocol.RESULT_ARGS_DIALOG_COMPLETION_GESTURE_KEY)) { return result.getString(NativeProtocol.RESULT_ARGS_DIALOG_COMPLETION_GESTURE_KEY); } return result.getString(NativeProtocol.EXTRA_DIALOG_COMPLETION_GESTURE_KEY); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // If an image is received, display it on the ImageView. if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) { Bundle extras = data.getExtras(); if (extras == null || !extras.containsKey(KEY_IMAGE_DATA)) { return; } Bitmap imageBitmap = (Bitmap) extras.get(KEY_IMAGE_DATA); mImageView.setImageBitmap(imageBitmap); } } }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) { if ((state != null) && state.containsKey(BUNDLE_POSITION) && state.containsKey(BUNDLE_BOOK)) { mPosition = state.getInt(BUNDLE_POSITION); mBook = (Book) state.getSerializable(BUNDLE_BOOK); mEpubFileName = state.getString(BUNDLE_EPUB_FILE_NAME); mIsSmilAvailable = state.getBoolean(BUNDLE_IS_SMIL_AVAILABLE); } return super.onCreateView(inflater, container, state); }
private Result(Bundle results) { this.requestId = results.getString(ShareConstants.WEB_DIALOG_RESULT_PARAM_REQUEST_ID); this.to = new ArrayList<String>(); while (results.containsKey(String.format( ShareConstants.WEB_DIALOG_RESULT_PARAM_TO_ARRAY_MEMBER, this.to.size()))) { this.to.add(results.getString(String.format( ShareConstants.WEB_DIALOG_RESULT_PARAM_TO_ARRAY_MEMBER, this.to.size()))); } }
public static AccessTokenSource getSource(Bundle bundle) { Validate.notNull(bundle, "bundle"); if (bundle.containsKey(TOKEN_SOURCE_KEY)) { return (AccessTokenSource) bundle.getSerializable(TOKEN_SOURCE_KEY); } else { boolean isSSO = bundle.getBoolean(IS_SSO_KEY); return isSSO ? AccessTokenSource.FACEBOOK_APPLICATION_WEB : AccessTokenSource.WEB_VIEW; } }
public static boolean isErrorResult(Intent resultIntent) { Bundle bridgeArgs = getBridgeArgumentsFromIntent(resultIntent); if (bridgeArgs != null) { return bridgeArgs.containsKey(BRIDGE_ARG_ERROR_BUNDLE); } else { return resultIntent.hasExtra(STATUS_ERROR_TYPE); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); if (args.containsKey(EXTRA_FILTER)) { filters.put(args.getString(EXTRA_FILTER), true); } }
@Override protected void onPostExecute(Bundle bundle) { if(bundle != null && bundle.containsKey(AccountManager.KEY_AUTHTOKEN)) { token = bundle.getString(AccountManager.KEY_AUTHTOKEN); //AQUtility.debug("stored auth", token); success(act); }else{ failure(act, AjaxStatus.AUTH_ERROR, "rejected"); } }
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null && getArguments().containsKey(ARG_LAYOUT_RES_ID)) { layoutResId = getArguments().getInt(ARG_LAYOUT_RES_ID); } }
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null && getArguments().containsKey(ARG_LAYOUT_RES_ID)) { layoutResId = getArguments().getInt(ARG_LAYOUT_RES_ID); } }
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null && getArguments().containsKey(ARG_LAYOUT_RES_ID)) { layoutResId = getArguments().getInt(ARG_LAYOUT_RES_ID); } }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(layout); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setTitle(getString(title)); actionBar.setDisplayHomeAsUpEnabled(true); } if (savedInstanceState != null && savedInstanceState.containsKey(BUNDLE_PAGE)) { page = savedInstanceState.getInt(BUNDLE_PAGE); } }
@Test public void containsKey() { assertThat(bundle.containsKey("foo")).isFalse(); bundle.putString("foo", "bar"); assertThat(bundle.containsKey("foo")).isTrue(); }
public static void assertEqualContents(final Bundle a, final Bundle b) { for (String key : a.keySet()) { if (!b.containsKey(key)) { Assert.fail("bundle does not include key " + key); } Assert.assertEquals(a.get(key), b.get(key)); } for (String key : b.keySet()) { if (!a.containsKey(key)) { Assert.fail("bundle does not include key " + key); } } }
@Override public void onCreate(Bundle savedInstanceState) { transcript.add("onCreate"); if (isRecreating) { assertTrue(savedInstanceState.containsKey("TestActivityKey")); assertEquals("TestActivityValue", savedInstanceState.getString("TestActivityKey")); } super.onCreate(savedInstanceState); }
@Test public void remove() { bundle.putFloat("foo", 5f); bundle.putFloat("foo2", 5f); bundle.remove("foo"); assertThat(bundle.containsKey("foo")).isFalse(); assertThat(bundle.containsKey("foo2")).isTrue(); }
@Override public void onActivityCreated(Bundle savedInstanceState) { if (getActivity() instanceof OrganizationSelectionProvider) { org = ((OrganizationSelectionProvider) getActivity()).addListener(this); } if (getArguments() != null && getArguments().containsKey("org")) { org = getArguments().getParcelable("org"); } if (org == null && savedInstanceState != null) { org = (User) savedInstanceState.get(EXTRA_USER); } super.onActivityCreated(savedInstanceState); }
@Override public void onRestoreInstanceState(Bundle savedInstanceState) { transcript.add("onRestoreInstanceState"); assertTrue(savedInstanceState.containsKey("TestActivityKey")); assertEquals("TestActivityValue", savedInstanceState.getString("TestActivityKey")); super.onRestoreInstanceState(savedInstanceState); }