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

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

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

Bundle.getShort介绍

暂无

代码示例

代码示例来源:origin: konmik/nucleus

when(bundle.getShort(anyString())).thenAnswer(get);
when(bundle.getShort(anyString(), anyShort())).thenAnswer(getOrDefault);
when(bundle.getShort(anyString())).thenAnswer(get);
when(bundle.getShort(anyString(), anyShort())).thenAnswer(getOrDefault);

代码示例来源:origin: kayoSun/Tack

public short getShort(String key,short defValue){
  if (mBundle != null) {
    return mBundle.getShort(key, defValue);
  }
  return defValue;
}
public short[] getShorts(String key){

代码示例来源:origin: evernote/android-state

public short getShort(Bundle state, String key) {
  return state.getShort(key + mBaseKey);
}

代码示例来源: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: fengdai/FragmentMaster

/**
 * Retrieve extended data from the request.
 *
 * @param name         The name of the desired item.
 * @param defaultValue the value to be returned if no value of the desired type is
 *                     stored with the given name.
 * @return the value of an item that previously added with putExtra() or the
 * default value if none was found.
 * @see #putExtra(String, short)
 */
public short getShortExtra(String name, short defaultValue) {
  return mExtras == null ? defaultValue : mExtras.getShort(name,
      defaultValue);
}

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

assertEquals(originalBundle.getByte(BYTE_KEY), cachedBundle.getByte(BYTE_KEY));
assertArrayEquals(originalBundle.getByteArray(BYTE_ARRAY_KEY), cachedBundle.getByteArray(BYTE_ARRAY_KEY));
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));

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

@Override
protected void onSaveInstanceState(Bundle outState) {
  oustate.putExtra("last_state", is_landscape);
  super.onSaveInstanceState(outState);
}

you can restore your position on on restore instance

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
  is_landscape = savedInstanceState.getShort("last_state");
  if (is_landscape == 0) {
    setRequestedOrientation(Configuration.ORIENTATION_LANDSCAPE);
  } else if (is_landscape == 1) {
    setRequestedOrientation(Configuration.ORIENTATION_PORTRAIT);
  }
  super.onRestoreInstanceState(savedInstanceState);
}

代码示例来源:origin: gkasten/drrickorang

private BufferCallbackTimes(Parcel source) {
  Bundle in = source.readBundle(getClass().getClassLoader());
  mTimeStamps = in.getIntArray("mTimeStamps");
  mCallbackDurations = in.getShortArray("mCallbackDurations");
  mExpectedBufferPeriod = in.getShort("mExpectedBufferPeriod");
  mExceededCapacity = in.getBoolean("mExceededCapacity");
  mIndex = in.getInt("mIndex");
}

代码示例来源:origin: evernote/android-state

public Short getBoxedShort(Bundle state, String key) {
  if (state.containsKey(key + mBaseKey)) {
    return state.getShort(key + mBaseKey);
  }
  return null;
}

代码示例来源:origin: maks/MGit

if (savedInstanceState != null) {
  fileName = savedInstanceState.getString(ViewFileActivity.TAG_FILE_NAME);
  mActivityMode = savedInstanceState.getShort(ViewFileActivity.TAG_MODE, ViewFileActivity.TAG_MODE_NORMAL);
  mActivityMode = getArguments().getShort(ViewFileActivity.TAG_MODE, ViewFileActivity.TAG_MODE_NORMAL);

代码示例来源:origin: sheimi/SGit

if (savedInstanceState != null) {
  fileName = savedInstanceState.getString(ViewFileActivity.TAG_FILE_NAME);
  mActivityMode = savedInstanceState.getShort(ViewFileActivity.TAG_MODE, ViewFileActivity.TAG_MODE_NORMAL);
  mActivityMode = getArguments().getShort(ViewFileActivity.TAG_MODE, ViewFileActivity.TAG_MODE_NORMAL);

代码示例来源:origin: Nimrodda/WizarDroid

args.putShort(field.getName(), context.getShort(field.getName()));

代码示例来源:origin: Meituan-Dianping/Shield

public static short getShortParam(String name, short defaultValue, Fragment fragment) {
  if (fragment.getArguments() != null && fragment.getArguments().containsKey(name)) {
    return fragment.getArguments().getShort(name);
  }
  Intent i = fragment.getActivity().getIntent();
  try {
    Uri uri = i.getData();
    if (uri != null) {
      String val = uri.getQueryParameter(name);
      if (!TextUtils.isEmpty(val))
        return Short.parseShort(val);
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
  return i.getShortExtra(name, defaultValue);
}

代码示例来源:origin: denzilferreira/aware-client

Short btDeviceRSSI = extras.getShort(BluetoothDevice.EXTRA_RSSI);

代码示例来源:origin: sheimi/SGit

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_view_file);
  mRepo = (Repo) getIntent().getSerializableExtra(Repo.TAG);
  mViewPager = (ViewPager) findViewById(R.id.pager);
  mTabItemPagerAdapter = new TabItemPagerAdapter(getFragmentManager());
  mViewPager.setAdapter(mTabItemPagerAdapter);
  mViewPager.setOnPageChangeListener(mTabItemPagerAdapter);
  Bundle b = new Bundle();
  Bundle extras = getIntent().getExtras();
  String fileName = extras.getString(TAG_FILE_NAME);
  mActivityMode = extras.getShort(TAG_MODE, TAG_MODE_NORMAL);
  b.putString(TAG_FILE_NAME, fileName);
  if (mRepo != null) {
    b.putSerializable(Repo.TAG, mRepo);
    mCommitsFragment = CommitsFragment.newInstance(mRepo, FsUtils.getRelativePath(new File(fileName), mRepo.getDir()));
  }
  if (mRepo == null) {
    PagerTitleStrip strip = (PagerTitleStrip) findViewById(R.id.pager_title_strip);
    strip.setVisibility(View.GONE);
  }
  mFileFragment = new ViewFileFragment();
  mFileFragment.setArguments(b);
  mActivityMode = extras.getShort(TAG_MODE, TAG_MODE_NORMAL);
  b.putInt(TAG_MODE, mActivityMode);
  getActionBar().setDisplayHomeAsUpEnabled(true);
  setTitle(new File(fileName).getName());
}

代码示例来源:origin: maks/MGit

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_view_file);
  mRepo = (Repo) getIntent().getSerializableExtra(Repo.TAG);
  mViewPager = (ViewPager) findViewById(R.id.pager);
  mTabItemPagerAdapter = new TabItemPagerAdapter(getSupportFragmentManager());
  mViewPager.setAdapter(mTabItemPagerAdapter);
  mViewPager.setOnPageChangeListener(mTabItemPagerAdapter);
  Bundle b = new Bundle();
  Bundle extras = getIntent().getExtras();
  String fileName = extras.getString(TAG_FILE_NAME);
  mActivityMode = extras.getShort(TAG_MODE, TAG_MODE_NORMAL);
  b.putString(TAG_FILE_NAME, fileName);
  if (mRepo != null) {
    b.putSerializable(Repo.TAG, mRepo);
    mCommitsFragment = CommitsFragment.newInstance(mRepo, FsUtils.getRelativePath(new File(fileName), mRepo.getDir()));
  }
  if (mRepo == null) {
    PagerTitleStrip strip = (PagerTitleStrip) findViewById(R.id.pager_title_strip);
    strip.setVisibility(View.GONE);
  }
  mFileFragment = new ViewFileFragment();
  mFileFragment.setArguments(b);
  mActivityMode = extras.getShort(TAG_MODE, TAG_MODE_NORMAL);
  b.putShort(TAG_MODE, mActivityMode);
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  setTitle(new File(fileName).getName());
}

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

return;
short sessionPort = data.getShort(PARAM_PORT);
doJoinSession(sessionhostBusName, sessionPort, resultReceiver);
break;

相关文章

Bundle类方法