Java Code Examples for com.google.android.gms.wearable.DataMap#putByteArray()
The following examples show how to use
com.google.android.gms.wearable.DataMap#putByteArray() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PersistenceTest.java From AndroidAPS with GNU Affero General Public License v3.0 | 6 votes |
@Test public void getDataMapTest() { // GIVEN Persistence persistence = new Persistence(); DataMap map = new DataMap(); map.putByteArray("test-key", new byte[]{9, 42, 127, -5}); // WHEN DataMap notExisting = persistence.getDataMap("not-there"); Persistence.storeDataMap("data-map", map); DataMap restoredMap = persistence.getDataMap("data-map"); byte[] restoredMapContents = restoredMap.getByteArray("test-key"); // THEN assertNull(notExisting); assertNotNull(restoredMap); assertTrue(restoredMap.containsKey("test-key")); assertThat(restoredMapContents.length, is(4)); assertThat(restoredMapContents[0], is((byte)9)); assertThat(restoredMapContents[1], is((byte)42)); assertThat(restoredMapContents[2], is((byte)127)); assertThat(restoredMapContents[3], is((byte)-5)); }
Example 2
Source File: ExceptionService.java From ExceptionWear with Apache License 2.0 | 6 votes |
private DataMap createExceptionInformation(Intent intent){ bos = new ByteArrayOutputStream(); try { oos = new ObjectOutputStream(bos); oos.writeObject(intent.getSerializableExtra(EXTRA_EXCEPTION)); } catch (IOException e) { Log.e(WearExceptionTools.EXCEPTION_WEAR_TAG, "createExceptionInformation error while getting exception information."); } byte[] exceptionData = bos.toByteArray(); DataMap dataMap = new DataMap(); // Add a bit of information on the Wear Device to pass a long with the exception dataMap.putString("board", Build.BOARD); dataMap.putString("fingerprint", Build.FINGERPRINT); dataMap.putString("model", Build.MODEL); dataMap.putString("manufacturer", Build.MANUFACTURER); dataMap.putString("product", Build.PRODUCT); dataMap.putString("api_level", Integer.toString(Build.VERSION.SDK_INT)); dataMap.putByteArray("exception", exceptionData); return dataMap; }
Example 3
Source File: ListenerService.java From xDrip with GNU General Public License v3.0 | 5 votes |
private synchronized void sendPersistentStore() { if (DexCollectionType.getDexCollectionType().equals(DexCollectionType.DexcomG5)) { DataMap dataMap = new DataMap(); String dex_txid = mPrefs.getString("dex_txid", "ABCDEF"); dataMap.putByteArray(G5_BATTERY_MARKER, PersistentStore.getBytes(G5_BATTERY_MARKER + dex_txid)); dataMap.putLong(G5_BATTERY_FROM_MARKER, PersistentStore.getLong(G5_BATTERY_FROM_MARKER + dex_txid)); dataMap.putString("dex_txid", dex_txid); dataMap.putByteArray(G5_FIRMWARE_MARKER, PersistentStore.getBytes(G5_FIRMWARE_MARKER + dex_txid)); dataMap.putString("dex_txid", dex_txid); sendData(WEARABLE_G5BATTERY_PAYLOAD, dataMap.toByteArray()); } }
Example 4
Source File: ListenerService.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
private synchronized void sendPersistentStore() { if (DexCollectionType.getDexCollectionType().equals(DexCollectionType.DexcomG5)) { DataMap dataMap = new DataMap(); String dex_txid = mPrefs.getString("dex_txid", "ABCDEF"); dataMap.putByteArray(G5_BATTERY_MARKER, PersistentStore.getBytes(G5_BATTERY_MARKER + dex_txid)); dataMap.putLong(G5_BATTERY_FROM_MARKER, PersistentStore.getLong(G5_BATTERY_FROM_MARKER + dex_txid)); dataMap.putString("dex_txid", dex_txid); dataMap.putByteArray(G5_FIRMWARE_MARKER, PersistentStore.getBytes(G5_FIRMWARE_MARKER + dex_txid)); dataMap.putString("dex_txid", dex_txid); sendData(WEARABLE_G5BATTERY_PAYLOAD, dataMap.toByteArray()); } }
Example 5
Source File: DataBundleUtil.java From android_external_GmsLib with Apache License 2.0 | 4 votes |
@Override void store(DataMap dataMap, String key, byte[] value) { dataMap.putByteArray(key, value); }