public short getShort(String key,short defValue){ if (mBundle != null) { return mBundle.getShort(key, defValue); } return defValue; } public short[] getShorts(String key){
public short getShort(Bundle state, String key) { return state.getShort(key + mBaseKey); }
@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); }
/** * 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); }
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));
@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); }
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"); }
public Short getBoxedShort(Bundle state, String key) { if (state.containsKey(key + mBaseKey)) { return state.getShort(key + mBaseKey); } return null; }
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);
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);
args.putShort(field.getName(), context.getShort(field.getName()));
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); }
Short btDeviceRSSI = extras.getShort(BluetoothDevice.EXTRA_RSSI);
@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()); }
@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()); }
return; short sessionPort = data.getShort(PARAM_PORT); doJoinSession(sessionhostBusName, sessionPort, resultReceiver); break;