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

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

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

Bundle.getInt介绍

暂无

代码示例

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

Bundle bundle = getIntent().getExtras();
int value = bundle.getInt("some_key");
String value2 = bundle.getString("some_other_key");

代码示例来源:origin: googlesamples/easypermissions

RationaleDialogConfig(Bundle bundle) {
  positiveButton = bundle.getString(KEY_POSITIVE_BUTTON);
  negativeButton = bundle.getString(KEY_NEGATIVE_BUTTON);
  rationaleMsg = bundle.getString(KEY_RATIONALE_MESSAGE);
  theme = bundle.getInt(KEY_THEME);
  requestCode = bundle.getInt(KEY_REQUEST_CODE);
  permissions = bundle.getStringArray(KEY_PERMISSIONS);
}

代码示例来源:origin: ankidroid/Anki-Android

@Override
public Message getDialogHandlerMessage() {
  Message msg = Message.obtain();
  msg.what = DialogHandler.MSG_SHOW_DATABASE_ERROR_DIALOG;
  Bundle b = new Bundle();
  b.putInt("dialogType", getArguments().getInt("dialogType"));
  msg.setData(b);
  return msg;
}

代码示例来源:origin: ankidroid/Anki-Android

@Override
public Message getDialogHandlerMessage() {
  Message msg = Message.obtain();
  msg.what = DialogHandler.MSG_SHOW_SYNC_ERROR_DIALOG;
  Bundle b = new Bundle();
  b.putInt("dialogType", getArguments().getInt("dialogType"));
  b.putString("dialogMessage", getArguments().getString("dialogMessage"));
  msg.setData(b);
  return msg;
}

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

@Test
public void getWrongType() {
 bundle.putFloat("foo", 5f);
 assertThat(bundle.getCharArray("foo")).isNull();
 assertThat(bundle.getInt("foo")).isEqualTo(0);
 assertThat(bundle.getIntArray("foo")).isNull();
 assertThat(bundle.getIntegerArrayList("foo")).isNull();
 assertThat(bundle.getShort("foo")).isEqualTo((short) 0);
 assertThat(bundle.getShortArray("foo")).isNull();
 assertThat(bundle.getBoolean("foo")).isFalse();
 assertThat(bundle.getBooleanArray("foo")).isNull();
 assertThat(bundle.getLong("foo")).isEqualTo(0);
 assertThat(bundle.getLongArray("foo")).isNull();
 assertThat(bundle.getFloatArray("foo")).isNull();
 assertThat(bundle.getDouble("foo")).isEqualTo(0.0);
 assertThat(bundle.getDoubleArray("foo")).isNull();
 assertThat(bundle.getString("foo")).isNull();
 assertThat(bundle.getStringArray("foo")).isNull();
 assertThat(bundle.getStringArrayList("foo")).isNull();
 assertThat(bundle.getBundle("foo")).isNull();
 assertThat((Parcelable) bundle.getParcelable("foo")).isNull();
 assertThat(bundle.getParcelableArray("foo")).isNull();
 assertThat(bundle.getParcelableArrayList("foo")).isNull();
 bundle.putInt("foo", 1);
 assertThat(bundle.getFloat("foo")).isEqualTo(0.0f);
}

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

innerBundle1.putInt("inner", 1);
b.putInt("intValue", 7);
b.putLong("longValue", 5000000000l);
b.putDouble("doubleValue", 3.14);
assertEquals(7, finalBundle.getInt("intValue"));
assertEquals(5000000000l, finalBundle.getLong("longValue"));
assertEquals(3.14, finalBundle.getDouble("doubleValue"), TestUtils.DOUBLE_EQUALS_DELTA);
assertEquals("hello world", finalBundle.getString("stringValue"));
assertEquals(1, finalInnerBundle.getInt("inner"));
finalBundle = finalInnerBundle.getBundle("nested bundle");
assertEquals("2", finalBundle.getString("inner"));

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

int response = purchaseDetails.getInt(RESPONSE_CODE);
if (response == 0) {
  ArrayList<String> details =
    queriedPurchaseNum += details.size();
    purchases.addAll(details);
    continuationToken = purchaseDetails.getString(INAPP_CONTINUATION_TOKEN);
  } else {
    break;

代码示例来源:origin: Yalantis/uCrop

private void processOptions(@NonNull Bundle bundle) {
  mCompressQuality = bundle.getInt(UCrop.Options.EXTRA_COMPRESSION_QUALITY, UCropActivity.DEFAULT_COMPRESS_QUALITY);
  mGestureCropImageView.setMaxBitmapSize(bundle.getInt(UCrop.Options.EXTRA_MAX_BITMAP_SIZE, CropImageView.DEFAULT_MAX_BITMAP_SIZE));
  mGestureCropImageView.setMaxScaleMultiplier(bundle.getFloat(UCrop.Options.EXTRA_MAX_SCALE_MULTIPLIER, CropImageView.DEFAULT_MAX_SCALE_MULTIPLIER));
  mGestureCropImageView.setImageToWrapCropBoundsAnimDuration(bundle.getInt(UCrop.Options.EXTRA_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION, CropImageView.DEFAULT_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION));
  mOverlayView.setDimmedColor(bundle.getInt(UCrop.Options.EXTRA_DIMMED_LAYER_COLOR, getResources().getColor(R.color.ucrop_color_default_dimmed)));
  mOverlayView.setCircleDimmedLayer(bundle.getBoolean(UCrop.Options.EXTRA_CIRCLE_DIMMED_LAYER, OverlayView.DEFAULT_CIRCLE_DIMMED_LAYER));
  mOverlayView.setCropFrameColor(bundle.getInt(UCrop.Options.EXTRA_CROP_FRAME_COLOR, getResources().getColor(R.color.ucrop_color_default_crop_frame)));
  mOverlayView.setCropFrameStrokeWidth(bundle.getInt(UCrop.Options.EXTRA_CROP_FRAME_STROKE_WIDTH, getResources().getDimensionPixelSize(R.dimen.ucrop_default_crop_frame_stoke_width)));
  mOverlayView.setCropGridRowCount(bundle.getInt(UCrop.Options.EXTRA_CROP_GRID_ROW_COUNT, OverlayView.DEFAULT_CROP_GRID_ROW_COUNT));
  mOverlayView.setCropGridColumnCount(bundle.getInt(UCrop.Options.EXTRA_CROP_GRID_COLUMN_COUNT, OverlayView.DEFAULT_CROP_GRID_COLUMN_COUNT));
  mOverlayView.setCropGridColor(bundle.getInt(UCrop.Options.EXTRA_CROP_GRID_COLOR, getResources().getColor(R.color.ucrop_color_default_crop_grid)));
  mOverlayView.setCropGridStrokeWidth(bundle.getInt(UCrop.Options.EXTRA_CROP_GRID_STROKE_WIDTH, getResources().getDimensionPixelSize(R.dimen.ucrop_default_crop_grid_stoke_width)));
  float aspectRatioY = bundle.getFloat(UCrop.EXTRA_ASPECT_RATIO_Y, 0);
  int aspectRationSelectedByDefault = bundle.getInt(UCrop.Options.EXTRA_ASPECT_RATIO_SELECTED_BY_DEFAULT, 0);
  ArrayList<AspectRatio> aspectRatioList = bundle.getParcelableArrayList(UCrop.Options.EXTRA_ASPECT_RATIO_OPTIONS);
  int maxSizeX = bundle.getInt(UCrop.EXTRA_MAX_SIZE_X, 0);
  int maxSizeY = bundle.getInt(UCrop.EXTRA_MAX_SIZE_Y, 0);

代码示例来源:origin: ankidroid/Anki-Android

@Override
  public Message getDialogHandlerMessage() {
    Message msg = Message.obtain();
    msg.what = DialogHandler.MSG_SHOW_MEDIA_CHECK_COMPLETE_DIALOG;
    Bundle b = new Bundle();
    b.putStringArrayList("nohave", getArguments().getStringArrayList("nohave"));
    b.putStringArrayList("unused", getArguments().getStringArrayList("unused"));
    b.putStringArrayList("invalid", getArguments().getStringArrayList("invalid"));
    b.putInt("dialogType", getArguments().getInt("dialogType"));
    msg.setData(b);
    return msg;
  }
}

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

assertEquals(originalBundle.getShort(SHORT_KEY), cachedBundle.getShort(SHORT_KEY));
assertArrayEquals(originalBundle.getShortArray(SHORT_ARRAY_KEY), cachedBundle.getShortArray(SHORT_ARRAY_KEY));
assertEquals(originalBundle.getInt(INT_KEY), cachedBundle.getInt(INT_KEY));
assertArrayEquals(originalBundle.getIntArray(INT_ARRAY_KEY), cachedBundle.getIntArray(INT_ARRAY_KEY));
assertEquals(originalBundle.getLong(LONG_KEY), cachedBundle.getLong(LONG_KEY));
assertEquals(originalBundle.getChar(CHAR_KEY), cachedBundle.getChar(CHAR_KEY));
assertArrayEquals(originalBundle.getCharArray(CHAR_ARRAY_KEY), cachedBundle.getCharArray(CHAR_ARRAY_KEY));
assertEquals(originalBundle.getString(STRING_KEY), cachedBundle.getString(STRING_KEY));
assertListEquals(originalBundle.getStringArrayList(STRING_LIST_KEY), cachedBundle.getStringArrayList(
    STRING_LIST_KEY));

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

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
 super.onRestoreInstanceState(savedInstanceState);
 // Restore UI state from the savedInstanceState.
 // This bundle has also been passed to onCreate.
 boolean myBoolean = savedInstanceState.getBoolean("MyBoolean");
 double myDouble = savedInstanceState.getDouble("myDouble");
 int myInt = savedInstanceState.getInt("MyInt");
 String myString = savedInstanceState.getString("MyString");
}

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

mStackLevel = savedInstanceState.getInt("level");
public void onSaveInstanceState(Bundle outState) {
  super.onSaveInstanceState(outState);
  outState.putInt("level", mStackLevel);

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

@Test
public void testMultipleCaches() {
  Bundle bundle1 = new Bundle(), bundle2 = new Bundle();
  bundle1.putInt(INT_KEY, 10);
  bundle1.putString(STRING_KEY, "ABC");
  bundle2.putInt(INT_KEY, 100);
  bundle2.putString(STRING_KEY, "xyz");
  ensureApplicationContext();
  LegacyTokenHelper cache1 = new LegacyTokenHelper(RuntimeEnvironment.application);
  LegacyTokenHelper cache2 = new LegacyTokenHelper(
      RuntimeEnvironment.application,
      "CustomCache");
  cache1.save(bundle1);
  cache2.save(bundle2);
  // Get new references to make sure we are getting persisted data.
  // Reverse the cache references for fun.
  cache1 = new LegacyTokenHelper(RuntimeEnvironment.application, "CustomCache");
  cache2 = new LegacyTokenHelper(RuntimeEnvironment.application);
  Bundle newBundle1 = cache1.load(), newBundle2 = cache2.load();
  assertEquals(bundle2.getInt(INT_KEY), newBundle1.getInt(INT_KEY));
  assertEquals(bundle2.getString(STRING_KEY), newBundle1.getString(STRING_KEY));
  assertEquals(bundle1.getInt(INT_KEY), newBundle2.getInt(INT_KEY));
  assertEquals(bundle1.getString(STRING_KEY), newBundle2.getString(STRING_KEY));
}

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

long nowSec = System.currentTimeMillis() / 1000L;
Bundle purchaseDetails = (Bundle) result;
int response = purchaseDetails.getInt(RESPONSE_CODE);
if (response == 0) {
  ArrayList<String> details =
  continuationToken = purchaseDetails.getString(INAPP_CONTINUATION_TOKEN);

代码示例来源:origin: TangoAgency/material-intro-screen

public void initializeView() {
  Bundle bundle = getArguments();
  backgroundColor = bundle.getInt(BACKGROUND_COLOR);
  buttonsColor = bundle.getInt(BUTTONS_COLOR);
  image = bundle.getInt(IMAGE, 0);
  title = bundle.getString(TITLE);
  description = bundle.getString(DESCRIPTION);
  neededPermissions = bundle.getStringArray(NEEDED_PERMISSIONS);
  possiblePermissions = bundle.getStringArray(POSSIBLE_PERMISSIONS);
  updateViewWithValues();
}

代码示例来源:origin: seven332/EhViewer

private void onRestore(Bundle savedInstanceState) {
  mAction = savedInstanceState.getString(KEY_ACTION);
  mGalleryInfo = savedInstanceState.getParcelable(KEY_GALLERY_INFO);
  mGid = savedInstanceState.getLong(KEY_GID);
  mToken = savedInstanceState.getString(KEY_TOKEN);
  mGalleryDetail = savedInstanceState.getParcelable(KEY_GALLERY_DETAIL);
  mRequestId = savedInstanceState.getInt(KEY_REQUEST_ID);
}

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

@Test
public void getInt() {
 bundle.putInt("foo", 5);
 assertThat(bundle.getInt("foo")).isEqualTo(5);
 assertThat(bundle.getInt("bar")).isEqualTo(0);
 assertThat(bundle.getInt("bar", 7)).isEqualTo(7);
}

代码示例来源:origin: bluelinelabs/Conductor

private void restoreInstanceState(@NonNull Bundle savedInstanceState) {
  viewState = savedInstanceState.getBundle(KEY_VIEW_STATE);
  if (viewState != null) {
    viewState.setClassLoader(getClass().getClassLoader());
  }
  instanceId = savedInstanceState.getString(KEY_INSTANCE_ID);
  targetInstanceId = savedInstanceState.getString(KEY_TARGET_INSTANCE_ID);
  requestedPermissions.addAll(savedInstanceState.getStringArrayList(KEY_REQUESTED_PERMISSIONS));
  overriddenPushHandler = ControllerChangeHandler.fromBundle(savedInstanceState.getBundle(KEY_OVERRIDDEN_PUSH_HANDLER));
  overriddenPopHandler = ControllerChangeHandler.fromBundle(savedInstanceState.getBundle(KEY_OVERRIDDEN_POP_HANDLER));
  needsAttach = savedInstanceState.getBoolean(KEY_NEEDS_ATTACH);
  retainViewMode = RetainViewMode.values()[savedInstanceState.getInt(KEY_RETAIN_VIEW_MODE, 0)];
  List<Bundle> childBundles = savedInstanceState.getParcelableArrayList(KEY_CHILD_ROUTERS);
  for (Bundle childBundle : childBundles) {
    ControllerHostedRouter childRouter = new ControllerHostedRouter();
    childRouter.restoreInstanceState(childBundle);
    childRouters.add(childRouter);
  }
  this.savedInstanceState = savedInstanceState.getBundle(KEY_SAVED_STATE);
  if (this.savedInstanceState != null) {
    this.savedInstanceState.setClassLoader(getClass().getClassLoader());
  }
  performOnRestoreInstanceState();
}

代码示例来源:origin: seven332/EhViewer

private void onRestore(@NonNull Bundle savedInstanceState) {
  mValid = savedInstanceState.getBoolean(KEY_VALID);
  mError = savedInstanceState.getString(KEY_ERROR);
  mAction = savedInstanceState.getString(KEY_ACTION);
  mGid = savedInstanceState.getLong(KEY_GID, -1);
  mPToken = savedInstanceState.getString(KEY_PTOKEN, null);
  mPage = savedInstanceState.getInt(KEY_PAGE, -1);
}

代码示例来源:origin: android-hacker/VirtualXposed

private ProcessRecord performStartProcessLocked(int vuid, int vpid, ApplicationInfo info, String processName) {
  ProcessRecord app = new ProcessRecord(info, processName, vuid, vpid);
  Bundle extras = new Bundle();
  BundleCompat.putBinder(extras, "_VA_|_binder_", app);
  extras.putInt("_VA_|_vuid_", vuid);
  extras.putString("_VA_|_process_", processName);
  extras.putString("_VA_|_pkg_", info.packageName);
  Bundle res = ProviderCall.call(VASettings.getStubAuthority(vpid), "_VA_|_init_process_", null, extras);
  if (res == null) {
    return null;
  }
  int pid = res.getInt("_VA_|_pid_");
  IBinder clientBinder = BundleCompat.getBinder(res, "_VA_|_client_");
  attachClient(pid, clientBinder);
  return app;
}

相关文章

Bundle类方法