List of usage examples for android.os Bundle putByte
@Override public void putByte(@Nullable String key, byte value)
From source file:it.sineo.android.tileMapEditor.TileMap.java
/** * Returns a Bundle representation of this map. No transient data is stored. * //from www . ja v a 2 s .c om * @return */ public Bundle toBundle() { Bundle b = new Bundle(); b.putString("name", name); b.putInt("rows", rows); b.putInt("columns", columns); b.putFloat("scale", scale); b.putFloat("xOff", xOff); b.putFloat("yOff", yOff); for (int idxRow = 0; idxRow < rows; idxRow++) { for (int idxCol = 0; idxCol < columns; idxCol++) { if (tilePaths[idxRow][idxCol] != null) { b.putString("paths_" + idxRow + "_" + idxCol, tilePaths[idxRow][idxCol]); b.putByte("angles_" + idxRow + "_" + idxCol, tileAngles[idxRow][idxCol]); } } } return b; }
From source file:com.frostwire.android.gui.fragments.MyFilesFragment.java
@Override public void onSaveInstanceState(Bundle outState) { outState.putByte(EXTRA_LAST_FILE_TYPE_CLICKED, lastFileType); super.onSaveInstanceState(outState); }
From source file:com.frostwire.android.gui.fragments.MyFilesFragment.java
private void reloadFiles(byte fileType) { try {/*from ww w.j a v a 2 s. c o m*/ if (isAdded()) { LoaderManager loaderManager = getLoaderManager(); loaderManager.destroyLoader(LOADER_FILES_ID); Bundle bundle = new Bundle(); bundle.putByte("fileType", fileType); loaderManager.restartLoader(LOADER_FILES_ID, bundle, this); } } catch (Throwable t) { LOG.error(t.getMessage(), t); } }
From source file:com.scooter1556.sms.android.activity.MainActivity.java
@Override public void MediaFolderSelected(MediaFolder folder) { // Create fragment and give it an argument for the selected folder Bundle arguments = new Bundle(); arguments.putLong("id", folder.getID()); arguments.putString("title", folder.getName()); arguments.putByte("directoryType", MediaElement.DirectoryMediaType.NONE); arguments.putBoolean("folder", true); mediaBrowserFragment = new MediaElementFragment(); mediaBrowserFragment.setArguments(arguments); mediaBrowserTitle = folder.getName(); getSupportFragmentManager().beginTransaction() .replace(R.id.main_container, mediaBrowserFragment, Integer.toString(MENU_MEDIA_BROWSER)) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE) .addToBackStack(Integer.toString(MENU_MEDIA_BROWSER)).commit(); updateDrawer(MENU_MEDIA_BROWSER);//from w w w .j av a2 s.c o m }
From source file:com.facebook.SharedPreferencesTokenCache.java
private void deserializeKey(String key, Bundle bundle) throws JSONException { String jsonString = cache.getString(key, "{}"); JSONObject json = new JSONObject(jsonString); String valueType = json.getString(JSON_VALUE_TYPE); if (valueType.equals(TYPE_BOOLEAN)) { bundle.putBoolean(key, json.getBoolean(JSON_VALUE)); } else if (valueType.equals(TYPE_BOOLEAN_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); boolean[] array = new boolean[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = jsonArray.getBoolean(i); }/*from w ww .j a v a 2s . c o m*/ bundle.putBooleanArray(key, array); } else if (valueType.equals(TYPE_BYTE)) { bundle.putByte(key, (byte) json.getInt(JSON_VALUE)); } else if (valueType.equals(TYPE_BYTE_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); byte[] array = new byte[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = (byte) jsonArray.getInt(i); } bundle.putByteArray(key, array); } else if (valueType.equals(TYPE_SHORT)) { bundle.putShort(key, (short) json.getInt(JSON_VALUE)); } else if (valueType.equals(TYPE_SHORT_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); short[] array = new short[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = (short) jsonArray.getInt(i); } bundle.putShortArray(key, array); } else if (valueType.equals(TYPE_INTEGER)) { bundle.putInt(key, json.getInt(JSON_VALUE)); } else if (valueType.equals(TYPE_INTEGER_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); int[] array = new int[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = jsonArray.getInt(i); } bundle.putIntArray(key, array); } else if (valueType.equals(TYPE_LONG)) { bundle.putLong(key, json.getLong(JSON_VALUE)); } else if (valueType.equals(TYPE_LONG_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); long[] array = new long[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = jsonArray.getLong(i); } bundle.putLongArray(key, array); } else if (valueType.equals(TYPE_FLOAT)) { bundle.putFloat(key, (float) json.getDouble(JSON_VALUE)); } else if (valueType.equals(TYPE_FLOAT_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); float[] array = new float[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = (float) jsonArray.getDouble(i); } bundle.putFloatArray(key, array); } else if (valueType.equals(TYPE_DOUBLE)) { bundle.putDouble(key, json.getDouble(JSON_VALUE)); } else if (valueType.equals(TYPE_DOUBLE_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); double[] array = new double[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = jsonArray.getDouble(i); } bundle.putDoubleArray(key, array); } else if (valueType.equals(TYPE_CHAR)) { String charString = json.getString(JSON_VALUE); if (charString != null && charString.length() == 1) { bundle.putChar(key, charString.charAt(0)); } } else if (valueType.equals(TYPE_CHAR_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); char[] array = new char[jsonArray.length()]; for (int i = 0; i < array.length; i++) { String charString = jsonArray.getString(i); if (charString != null && charString.length() == 1) { array[i] = charString.charAt(0); } } bundle.putCharArray(key, array); } else if (valueType.equals(TYPE_STRING)) { bundle.putString(key, json.getString(JSON_VALUE)); } else if (valueType.equals(TYPE_STRING_LIST)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); int numStrings = jsonArray.length(); ArrayList<String> stringList = new ArrayList<String>(numStrings); for (int i = 0; i < numStrings; i++) { Object jsonStringValue = jsonArray.get(i); stringList.add(i, jsonStringValue == JSONObject.NULL ? null : (String) jsonStringValue); } bundle.putStringArrayList(key, stringList); } }
From source file:com.facebook.LegacyTokenHelper.java
private void deserializeKey(String key, Bundle bundle) throws JSONException { String jsonString = cache.getString(key, "{}"); JSONObject json = new JSONObject(jsonString); String valueType = json.getString(JSON_VALUE_TYPE); if (valueType.equals(TYPE_BOOLEAN)) { bundle.putBoolean(key, json.getBoolean(JSON_VALUE)); } else if (valueType.equals(TYPE_BOOLEAN_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); boolean[] array = new boolean[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = jsonArray.getBoolean(i); }// www . java2 s .c o m bundle.putBooleanArray(key, array); } else if (valueType.equals(TYPE_BYTE)) { bundle.putByte(key, (byte) json.getInt(JSON_VALUE)); } else if (valueType.equals(TYPE_BYTE_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); byte[] array = new byte[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = (byte) jsonArray.getInt(i); } bundle.putByteArray(key, array); } else if (valueType.equals(TYPE_SHORT)) { bundle.putShort(key, (short) json.getInt(JSON_VALUE)); } else if (valueType.equals(TYPE_SHORT_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); short[] array = new short[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = (short) jsonArray.getInt(i); } bundle.putShortArray(key, array); } else if (valueType.equals(TYPE_INTEGER)) { bundle.putInt(key, json.getInt(JSON_VALUE)); } else if (valueType.equals(TYPE_INTEGER_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); int[] array = new int[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = jsonArray.getInt(i); } bundle.putIntArray(key, array); } else if (valueType.equals(TYPE_LONG)) { bundle.putLong(key, json.getLong(JSON_VALUE)); } else if (valueType.equals(TYPE_LONG_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); long[] array = new long[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = jsonArray.getLong(i); } bundle.putLongArray(key, array); } else if (valueType.equals(TYPE_FLOAT)) { bundle.putFloat(key, (float) json.getDouble(JSON_VALUE)); } else if (valueType.equals(TYPE_FLOAT_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); float[] array = new float[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = (float) jsonArray.getDouble(i); } bundle.putFloatArray(key, array); } else if (valueType.equals(TYPE_DOUBLE)) { bundle.putDouble(key, json.getDouble(JSON_VALUE)); } else if (valueType.equals(TYPE_DOUBLE_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); double[] array = new double[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = jsonArray.getDouble(i); } bundle.putDoubleArray(key, array); } else if (valueType.equals(TYPE_CHAR)) { String charString = json.getString(JSON_VALUE); if (charString != null && charString.length() == 1) { bundle.putChar(key, charString.charAt(0)); } } else if (valueType.equals(TYPE_CHAR_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); char[] array = new char[jsonArray.length()]; for (int i = 0; i < array.length; i++) { String charString = jsonArray.getString(i); if (charString != null && charString.length() == 1) { array[i] = charString.charAt(0); } } bundle.putCharArray(key, array); } else if (valueType.equals(TYPE_STRING)) { bundle.putString(key, json.getString(JSON_VALUE)); } else if (valueType.equals(TYPE_STRING_LIST)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE); int numStrings = jsonArray.length(); ArrayList<String> stringList = new ArrayList<String>(numStrings); for (int i = 0; i < numStrings; i++) { Object jsonStringValue = jsonArray.get(i); stringList.add(i, jsonStringValue == JSONObject.NULL ? null : (String) jsonStringValue); } bundle.putStringArrayList(key, stringList); } else if (valueType.equals(TYPE_ENUM)) { try { String enumType = json.getString(JSON_VALUE_ENUM_TYPE); @SuppressWarnings({ "unchecked", "rawtypes" }) Class<? extends Enum> enumClass = (Class<? extends Enum>) Class.forName(enumType); @SuppressWarnings("unchecked") Enum<?> enumValue = Enum.valueOf(enumClass, json.getString(JSON_VALUE)); bundle.putSerializable(key, enumValue); } catch (ClassNotFoundException e) { } catch (IllegalArgumentException e) { } } }
From source file:com.github.google.beaconfig.BeaconConfigActivity.java
/** * Reads information about the beacon from the gatt client. It creates a fragment * for each slot of the beacon and puts it in the tab layout. Then all the available information * about this slot is read and displayed on the screen * * All operations do not involve UI are done on the background thread *//*from w ww .j a v a 2s. c om*/ private void setUpFragments() { executor.execute(new Runnable() { @Override public void run() { try { byte[] data = gattClient.readBroadcastCapabilities(); capabilities = new BroadcastCapabilities(data); Bundle globalDataBundle = new Bundle(); globalDataBundle.putByteArray(Constants.BROADCAST_CAPABILITIES, data); globalDataBundle.putString(Constants.BEACON_ADDRESS, address); globalDataBundle.putString(Constants.BEACON_NAME, name); byte[] remainConnectable = gattClient.readRemainConnectable(); globalDataBundle.putByte(Constants.REMAIN_CONNECTABLE, remainConnectable[0]); if (!capabilities.isVariableTxPowerSupported()) { String radioTxPower = Integer.toString(gattClient.readRadioTxPower()[0]); String advTxPower = Integer.toString(gattClient.readAdvertisedTxPower()[0]); globalDataBundle.putString(Constants.TX_POWER, radioTxPower); globalDataBundle.putString(Constants.ADV_POWER, advTxPower); } if (!capabilities.isVariableAdvSupported()) { String advInterval = Integer.toString(Utils.toInt(gattClient.readAdvertisingInterval())); globalDataBundle.putString(Constants.ADV_INTERVAL, advInterval); } GlobalFragment globalFragment = GlobalFragment.newInstance(globalDataBundle); slotsAdapter.addFragment(globalFragment); for (int i = 0; i < capabilities.getMaxSupportedTotalSlots(); i++) { gattClient.writeActiveSlot(i); final Bundle slotInfoBundle = new Bundle(); final byte[] slotData = gattClient.readAdvSlotData(); slotInfoBundle.putByteArray(Constants.SLOT_DATA, slotData); if (capabilities.isVariableTxPowerSupported()) { String radioTxPower = Integer.toString(gattClient.readRadioTxPower()[0]); String advTxPower = Integer.toString(gattClient.readAdvertisedTxPower()[0]); slotInfoBundle.putString(Constants.TX_POWER, radioTxPower); slotInfoBundle.putString(Constants.ADV_POWER, advTxPower); } if (capabilities.isVariableAdvSupported()) { String advInterval = Integer .toString(Utils.toInt(gattClient.readAdvertisingInterval())); slotInfoBundle.putString(Constants.ADV_INTERVAL, advInterval); } slotInfoBundle.putByteArray(Constants.BROADCAST_CAPABILITIES, data); slotInfoBundle.putInt(Constants.SLOT_NUMBER, i); slotsAdapter.createNewFragment(slotInfoBundle); runOnUiThread(new Runnable() { @Override public void run() { slotsAdapter.notifyDataSetChanged(); } }); } runOnUiThread(new Runnable() { @Override public void run() { viewPager.setOffscreenPageLimit(capabilities.getMaxSupportedTotalSlots()); setTabTitles(); enableDisplay(); findViewById(R.id.tab_layout).setVisibility(View.VISIBLE); } }); } catch (GattClientException e) { Log.d(TAG, "Gatt Client Error when getting information from beacon", e); displayConnectionFailScreen("Something went wrong when getting information " + "from beacon"); } catch (GattOperationException e) { Log.d(TAG, "Gatt Operation Error when getting information from beacon", e); displayConnectionFailScreen("Something went wrong when getting information " + "from beacon"); } } }); }
From source file:com.scooter1556.sms.android.activity.MainActivity.java
@Override public void MediaElementSelected(MediaElement element) { if (element.getType().equals(MediaElement.MediaElementType.DIRECTORY)) { Bundle arguments = new Bundle(); if (element.getDirectoryType().equals(MediaElement.DirectoryMediaType.AUDIO)) { arguments.putLong("id", element.getID()); arguments.putString("title", element.getTitle()); arguments.putString("artist", element.getArtist()); mediaBrowserFragment = new AudioDirectoryFragment(); } else {/*from w ww.j av a 2s .c om*/ arguments.putLong("id", element.getID()); arguments.putString("title", element.getTitle()); arguments.putByte("directoryType", element.getDirectoryType()); arguments.putBoolean("folder", false); mediaBrowserFragment = new MediaElementFragment(); } mediaBrowserFragment.setArguments(arguments); getSupportFragmentManager().beginTransaction() .replace(R.id.main_container, mediaBrowserFragment, Integer.toString(MENU_MEDIA_BROWSER)) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE) .addToBackStack(Integer.toString(MENU_MEDIA_BROWSER)).commit(); updateDrawer(MENU_MEDIA_BROWSER); } else if (element.getType().equals(MediaElement.MediaElementType.AUDIO)) { audioPlayerService.addAndPlay(element); } else if (element.getType().equals(MediaElement.MediaElementType.VIDEO)) { // Make sure Audio Service is not playing if (audioPlayerService.isPlaying()) { audioPlayerService.stop(); } // Load video player Intent i = new Intent(this, VideoPlayerActivity.class); i.putExtra("mediaElement", element); startActivity(i); } }
From source file:cn.edu.zafu.corepage.base.BaseActivity.java
/** * ??//from www . ja v a 2 s . c o m * * @param outState Bundle */ @Override protected void onSaveInstanceState(Bundle outState) { Field[] fields = this.getClass().getDeclaredFields(); Field.setAccessible(fields, true); Annotation[] ans; for (Field f : fields) { ans = f.getDeclaredAnnotations(); for (Annotation an : ans) { if (an instanceof SaveWithActivity) { try { Object o = f.get(this); if (o == null) { continue; } String fieldName = f.getName(); if (o instanceof Integer) { outState.putInt(fieldName, f.getInt(this)); } else if (o instanceof String) { outState.putString(fieldName, (String) f.get(this)); } else if (o instanceof Long) { outState.putLong(fieldName, f.getLong(this)); } else if (o instanceof Short) { outState.putShort(fieldName, f.getShort(this)); } else if (o instanceof Boolean) { outState.putBoolean(fieldName, f.getBoolean(this)); } else if (o instanceof Byte) { outState.putByte(fieldName, f.getByte(this)); } else if (o instanceof Character) { outState.putChar(fieldName, f.getChar(this)); } else if (o instanceof CharSequence) { outState.putCharSequence(fieldName, (CharSequence) f.get(this)); } else if (o instanceof Float) { outState.putFloat(fieldName, f.getFloat(this)); } else if (o instanceof Double) { outState.putDouble(fieldName, f.getDouble(this)); } else if (o instanceof String[]) { outState.putStringArray(fieldName, (String[]) f.get(this)); } else if (o instanceof Parcelable) { outState.putParcelable(fieldName, (Parcelable) f.get(this)); } else if (o instanceof Serializable) { outState.putSerializable(fieldName, (Serializable) f.get(this)); } else if (o instanceof Bundle) { outState.putBundle(fieldName, (Bundle) f.get(this)); } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } } } super.onSaveInstanceState(outState); }