android.os.Bundle.containsKey()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(410)

本文整理了Java中android.os.Bundle.containsKey()方法的一些代码示例,展示了Bundle.containsKey()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.containsKey()方法的具体详情如下:
包路径:android.os.Bundle
类名称:Bundle
方法名:containsKey

Bundle.containsKey介绍

暂无

代码示例

代码示例来源:origin: ogaclejapan/SmartTabLayout

public static boolean hasPosition(Bundle args) {
 return args != null && args.containsKey(KEY_POSITION);
}

代码示例来源:origin: stackoverflow.com

// 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.
  }
}

代码示例来源:origin: facebook/facebook-android-sdk

/**
 * 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);
}

代码示例来源:origin: googlesamples/android-testing

@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);
    }
  }
}

代码示例来源:origin: smuyyh/BookReader

@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);
}

代码示例来源:origin: facebook/facebook-android-sdk

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())));
  }
}

代码示例来源:origin: facebook/facebook-android-sdk

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;
  }
}

代码示例来源:origin: facebook/facebook-android-sdk

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);
  }
}

代码示例来源:origin: pockethub/PocketHub

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  Bundle args = getArguments();
  if (args.containsKey(EXTRA_FILTER)) {
    filters.put(args.getString(EXTRA_FILTER), true);
  }
}

代码示例来源:origin: androidquery/androidquery

@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");
  }
  
}

代码示例来源:origin: AppIntro/AppIntro

@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);
  }
}

代码示例来源:origin: guardianproject/haven

@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);
  }
}

代码示例来源:origin: guardianproject/haven

@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);
  }
}

代码示例来源:origin: davemorrissey/subsampling-scale-image-view

@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);
  }
}

代码示例来源:origin: robolectric/robolectric

@Test
public void containsKey() {
 assertThat(bundle.containsKey("foo")).isFalse();
 bundle.putString("foo", "bar");
 assertThat(bundle.containsKey("foo")).isTrue();
}

代码示例来源:origin: facebook/facebook-android-sdk

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);
    }
  }
}

代码示例来源:origin: robolectric/robolectric

@Override
public void onCreate(Bundle savedInstanceState) {
 transcript.add("onCreate");
 if (isRecreating) {
  assertTrue(savedInstanceState.containsKey("TestActivityKey"));
  assertEquals("TestActivityValue", savedInstanceState.getString("TestActivityKey"));
 }
 super.onCreate(savedInstanceState);
}

代码示例来源:origin: robolectric/robolectric

@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();
}

代码示例来源:origin: pockethub/PocketHub

@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);
}

代码示例来源:origin: robolectric/robolectric

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
 transcript.add("onRestoreInstanceState");
 assertTrue(savedInstanceState.containsKey("TestActivityKey"));
 assertEquals("TestActivityValue", savedInstanceState.getString("TestActivityKey"));
 super.onRestoreInstanceState(savedInstanceState);
}

相关文章

Bundle类方法