Java Code Examples for android.os.bundle#putByteArray()
The following examples show how to use
android.os.bundle#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: MediaPlayer.java From Vitamio with Apache License 2.0 | 6 votes |
private void updateSub(int subType, byte[] bytes, String encoding, int width, int height) { if (mEventHandler != null) { Message m = mEventHandler.obtainMessage(MEDIA_TIMED_TEXT, width, height); Bundle b = m.getData(); if (subType == SUBTITLE_TEXT) { b.putInt(MEDIA_SUBTITLE_TYPE, SUBTITLE_TEXT); if (encoding == null) { b.putString(MEDIA_SUBTITLE_STRING, new String(bytes)); } else { try { b.putString(MEDIA_SUBTITLE_STRING, new String(bytes, encoding.trim())); } catch (UnsupportedEncodingException e) { Log.e("updateSub", e); b.putString(MEDIA_SUBTITLE_STRING, new String(bytes)); } } } else if (subType == SUBTITLE_BITMAP) { b.putInt(MEDIA_SUBTITLE_TYPE, SUBTITLE_BITMAP); b.putByteArray(MEDIA_SUBTITLE_BYTES, bytes); } mEventHandler.sendMessage(m); } }
Example 2
Source File: MediaPlayer.java From HPlayer with Apache License 2.0 | 6 votes |
private void updateSub(int subType, byte[] bytes, String encoding, int width, int height) { if (mEventHandler != null) { Message m = mEventHandler.obtainMessage(MEDIA_TIMED_TEXT, width, height); Bundle b = m.getData(); if (subType == SUBTITLE_TEXT) { b.putInt(MEDIA_SUBTITLE_TYPE, SUBTITLE_TEXT); if (encoding == null) { b.putString(MEDIA_SUBTITLE_STRING, new String(bytes)); } else { try { b.putString(MEDIA_SUBTITLE_STRING, new String(bytes, encoding.trim())); } catch (UnsupportedEncodingException e) { Log.e("updateSub", e); b.putString(MEDIA_SUBTITLE_STRING, new String(bytes)); } } } else if (subType == SUBTITLE_BITMAP) { b.putInt(MEDIA_SUBTITLE_TYPE, SUBTITLE_BITMAP); b.putByteArray(MEDIA_SUBTITLE_BYTES, bytes); } mEventHandler.sendMessage(m); } }
Example 3
Source File: WXMediaMessage$Builder.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
public static Bundle toBundle(WXMediaMessage wxmediamessage) { Bundle bundle = new Bundle(); bundle.putInt("_wxobject_sdkVer", wxmediamessage.sdkVer); bundle.putString("_wxobject_title", wxmediamessage.title); bundle.putString("_wxobject_description", wxmediamessage.description); bundle.putByteArray("_wxobject_thumbdata", wxmediamessage.thumbData); if (wxmediamessage.mediaObject != null) { bundle.putString("_wxobject_identifier_", a(wxmediamessage.mediaObject.getClass().getName())); wxmediamessage.mediaObject.serialize(bundle); } bundle.putString("_wxobject_mediatagname", wxmediamessage.mediaTagName); bundle.putString("_wxobject_message_action", wxmediamessage.messageAction); bundle.putString("_wxobject_message_ext", wxmediamessage.messageExt); return bundle; }
Example 4
Source File: DecodeHandler.java From Android with MIT License | 5 votes |
private static void bundleThumbnail(PlanarYUVLuminanceSource source, Bundle bundle) { int[] pixels = source.renderThumbnail(); int width = source.getThumbnailWidth(); int height = source.getThumbnailHeight(); Bitmap bitmap = Bitmap.createBitmap(pixels, 0, width, width, height, Bitmap.Config.ARGB_8888); ByteArrayOutputStream out = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 50, out); bundle.putByteArray(DecodeThread.BARCODE_BITMAP, out.toByteArray()); }
Example 5
Source File: MainActivity.java From QuickLyric with GNU General Public License v3.0 | 5 votes |
public void updateLyricsFragment(int outAnim, int inAnim, boolean transition, boolean lock, Lyrics lyrics) { LyricsViewFragment lyricsViewFragment = (LyricsViewFragment) getFragmentManager().findFragmentByTag(LYRICS_FRAGMENT_TAG); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.setCustomAnimations(inAnim, outAnim, inAnim, outAnim); Fragment activeFragment = getDisplayedFragment(getActiveFragments()); if (lyricsViewFragment != null && lyricsViewFragment.getView() != null) { SharedPreferences preferences = getSharedPreferences("current_music", Context.MODE_PRIVATE); String artist = preferences.getString("artist", null); String track = preferences.getString("track", null); if (lyrics.isLRC() && !(lyrics.getOriginalArtist().equals(artist) && lyrics.getOriginalTitle().equals(track))) { LrcView parser = new LrcView(this, null); parser.setOriginalLyrics(lyrics); parser.setSourceLrc(lyrics.getText()); lyrics = parser.getStaticLyrics(); } lyricsViewFragment.manualUpdateLock = lock; lyricsViewFragment.update(lyrics, lyricsViewFragment.getView(), true); if (transition) { fragmentTransaction.hide(activeFragment).show(lyricsViewFragment); prepareAnimations(activeFragment); prepareAnimations(lyricsViewFragment); } showRefreshFab(true); lyricsViewFragment.expandToolbar(); } else { Bundle lyricsBundle = new Bundle(); try { lyricsBundle.putByteArray("lyrics", lyrics.toBytes()); } catch (IOException e) { e.printStackTrace(); } lyricsViewFragment = new LyricsViewFragment(); lyricsViewFragment.setArguments(lyricsBundle); if (!(activeFragment instanceof LyricsViewFragment) && activeFragment != null) fragmentTransaction.hide(activeFragment).add(id.main_fragment_container, lyricsViewFragment, LYRICS_FRAGMENT_TAG); else fragmentTransaction.replace(id.main_fragment_container, lyricsViewFragment, LYRICS_FRAGMENT_TAG); } fragmentTransaction.commitAllowingStateLoss(); }
Example 6
Source File: BundleSerializer.java From white-label-event-app with Apache License 2.0 | 5 votes |
public void serialize(T t, Bundle bundle) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(64); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(t); oos.close(); bundle.putByteArray(bundleProperty, baos.toByteArray()); } catch (Exception e) { throw new RuntimeException(e); } }
Example 7
Source File: UnlockBeaconDialogFragment.java From Android-nRF-Beacon-for-Eddystone with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static UnlockBeaconDialogFragment newInstance(byte [] challenge, final String message){ UnlockBeaconDialogFragment fragment = new UnlockBeaconDialogFragment(); final Bundle args = new Bundle(); args.putByteArray(CHALLENGE, challenge); args.putString(UNLOCK_MESSAGE, message); fragment.setArguments(args); return fragment; }
Example 8
Source File: Utility.java From facebook-api-android-maven with Apache License 2.0 | 5 votes |
public static void putObjectInBundle(Bundle bundle, String key, Object value) { if (value instanceof String) { bundle.putString(key, (String) value); } else if (value instanceof Parcelable) { bundle.putParcelable(key, (Parcelable) value); } else if (value instanceof byte[]) { bundle.putByteArray(key, (byte[]) value); } else { throw new FacebookException("attempted to add unsupported type to Bundle"); } }
Example 9
Source File: FacebookShareActivity.java From FacebookImageShareIntent with MIT License | 5 votes |
private void postImageToFacebook() { Session session = Session.getActiveSession(); final Uri uri = (Uri) mExtras.get(Intent.EXTRA_STREAM); final String extraText = mPostTextView.getText().toString(); if (session.isPermissionGranted("publish_actions")) { Bundle param = new Bundle(); // Add the image try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); byte[] byteArrayData = stream.toByteArray(); param.putByteArray("picture", byteArrayData); } catch (IOException ioe) { // The image that was send through is now not there? Assert.assertTrue(false); } // Add the caption param.putString("message", extraText); Request request = new Request(session,"me/photos", param, HttpMethod.POST, new Request.Callback() { @Override public void onCompleted(Response response) { addNotification(getString(R.string.photo_post), response.getGraphObject(), response.getError()); } }, null); RequestAsyncTask asyncTask = new RequestAsyncTask(request); asyncTask.execute(); finish(); } }
Example 10
Source File: DecodeHandler.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 处理缩略图 * @param source {@link PlanarYUVLuminanceSource} * @param bundle 存储数据 {@link Bundle} */ private static void bundleThumbnail(PlanarYUVLuminanceSource source, Bundle bundle) { int[] pixels = source.renderThumbnail(); int width = source.getThumbnailWidth(); int height = source.getThumbnailHeight(); Bitmap bitmap = Bitmap.createBitmap(pixels, 0, width, width, height, Bitmap.Config.ARGB_8888); ByteArrayOutputStream out = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 50, out); bundle.putByteArray(DecodeConfig.BARCODE_BITMAP, out.toByteArray()); }
Example 11
Source File: DecodeHandler.java From Gizwits-SmartBuld_Android with MIT License | 5 votes |
private static void bundleThumbnail(PlanarYUVLuminanceSource source, Bundle bundle) { int[] pixels = source.renderThumbnail(); int width = source.getThumbnailWidth(); int height = source.getThumbnailHeight(); Bitmap bitmap = Bitmap.createBitmap(pixels, 0, width, width, height, Bitmap.Config.ARGB_8888); ByteArrayOutputStream out = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 50, out); bundle.putByteArray(DecodeThread.BARCODE_BITMAP, out.toByteArray()); }
Example 12
Source File: Utility.java From kakao-android-sdk-standalone with Apache License 2.0 | 5 votes |
public static void putObjectInBundle(final Bundle bundle, final String key, final Object value) { if (value instanceof String) { bundle.putString(key, (String) value); } else if (value instanceof Parcelable) { bundle.putParcelable(key, (Parcelable) value); } else if (value instanceof byte[]) { bundle.putByteArray(key, (byte[]) value); } else { throw new KakaoException("attempted to add unsupported type to Bundle"); } }
Example 13
Source File: Utility.java From FacebookNewsfeedSample-Android with Apache License 2.0 | 5 votes |
public static void putObjectInBundle(Bundle bundle, String key, Object value) { if (value instanceof String) { bundle.putString(key, (String) value); } else if (value instanceof Parcelable) { bundle.putParcelable(key, (Parcelable) value); } else if (value instanceof byte[]) { bundle.putByteArray(key, (byte[]) value); } else { throw new FacebookException("attempted to add unsupported type to Bundle"); } }
Example 14
Source File: DecodeHandler.java From GOpenSource_AppKit_Android_AS with MIT License | 5 votes |
private static void bundleThumbnail(PlanarYUVLuminanceSource source, Bundle bundle) { int[] pixels = source.renderThumbnail(); int width = source.getThumbnailWidth(); int height = source.getThumbnailHeight(); Bitmap bitmap = Bitmap.createBitmap(pixels, 0, width, width, height, Bitmap.Config.ARGB_8888); ByteArrayOutputStream out = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 50, out); bundle.putByteArray(DecodeThread.BARCODE_BITMAP, out.toByteArray()); }
Example 15
Source File: RulerOverlay.java From android_maplibui with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Bundle onSaveState() { Bundle bundle = super.onSaveState(); try { if (isMeasuring() && mRulerPolygon != null) bundle.putByteArray(BUNDLE_GEOMETRY, mRulerString.toBlob()); } catch (IOException e) { e.printStackTrace(); } return bundle; }
Example 16
Source File: LibreOOPAlgorithm.java From xDrip with GNU General Public License v3.0 | 4 votes |
static public void SendData(byte[] fullData, long timestamp, byte []patchUid, byte []patchInfo) { if(fullData == null) { Log.e(TAG, "SendData called with null data"); return; } if(fullData.length < 344) { Log.e(TAG, "SendData called with data size too small. " + fullData.length); return; } Log.i(TAG, "Sending full data to OOP Algorithm data-len = " + fullData.length); fullData = java.util.Arrays.copyOfRange(fullData, 0, 0x158); Log.i(TAG, "Data that will be sent is " + HexDump.dumpHexString(fullData)); Intent intent = new Intent(Intents.XDRIP_PLUS_LIBRE_DATA); Bundle bundle = new Bundle(); bundle.putByteArray(Intents.LIBRE_DATA_BUFFER, fullData); bundle.putLong(Intents.LIBRE_DATA_TIMESTAMP, timestamp); bundle.putString(Intents.LIBRE_SN, PersistentStore.getString("LibreSN")); if(patchUid != null) { bundle.putByteArray(Intents.LIBRE_PATCH_UID_BUFFER, patchUid); } if(patchInfo != null) { bundle.putByteArray(Intents.LIBRE_PATCH_INFO_BUFFER, patchInfo); } intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); final String packages = PersistentStore.getString(CompatibleApps.EXTERNAL_ALG_PACKAGES); if (packages.length() > 0) { final String[] packagesE = packages.split(","); for (final String destination : packagesE) { if (destination.length() > 3) { intent.setPackage(destination); Log.d(TAG, "Sending to package: " + destination); xdrip.getAppContext().sendBroadcast(intent); } } } else { Log.d(TAG, "Sending to generic package"); xdrip.getAppContext().sendBroadcast(intent); } }
Example 17
Source File: ServiceFactory.java From nfcspy with GNU General Public License v3.0 | 4 votes |
static void setDataToMessage(Message msg, byte[] raw) { Bundle data = new Bundle(); data.putByteArray(KEY_BLOB, raw); msg.setData(data); }
Example 18
Source File: Hackbook.java From FacebookNewsfeedSample-Android with Apache License 2.0 | 4 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { /* * if this is the activity result from authorization flow, do a call * back to authorizeCallback Source Tag: login_tag */ case AUTHORIZE_ACTIVITY_RESULT_CODE: { Utility.mFacebook.authorizeCallback(requestCode, resultCode, data); break; } /* * if this is the result for a photo picker from the gallery, upload * the image after scaling it. You can use the Utility.scaleImage() * function for scaling */ case PICK_EXISTING_PHOTO_RESULT_CODE: { if (resultCode == Activity.RESULT_OK) { Uri photoUri = data.getData(); if (photoUri != null) { Bundle params = new Bundle(); try { params.putByteArray("photo", Utility.scaleImage(getApplicationContext(), photoUri)); } catch (IOException e) { e.printStackTrace(); } params.putString("caption", "FbAPIs Sample App photo upload"); Utility.mAsyncRunner.request("me/photos", params, "POST", new PhotoUploadListener(), null); } else { Toast.makeText(getApplicationContext(), "Error selecting image from the gallery.", Toast.LENGTH_SHORT) .show(); } } else { Toast.makeText(getApplicationContext(), "No image selected for upload.", Toast.LENGTH_SHORT).show(); } break; } } }
Example 19
Source File: WXAppExtendObject.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
public void serialize(Bundle bundle) { bundle.putString("_wxappextendobject_extInfo", extInfo); bundle.putByteArray("_wxappextendobject_fileData", fileData); bundle.putString("_wxappextendobject_filePath", filePath); }
Example 20
Source File: LibreOOPAlgorithm.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
static public void SendData(byte[] fullData, long timestamp, byte []patchUid, byte []patchInfo) { if(fullData == null) { Log.e(TAG, "SendData called with null data"); return; } if(fullData.length < 344) { Log.e(TAG, "SendData called with data size too small. " + fullData.length); return; } Log.i(TAG, "Sending full data to OOP Algorithm data-len = " + fullData.length); fullData = java.util.Arrays.copyOfRange(fullData, 0, 0x158); Log.i(TAG, "Data that will be sent is " + HexDump.dumpHexString(fullData)); Intent intent = new Intent(Intents.XDRIP_PLUS_LIBRE_DATA); Bundle bundle = new Bundle(); bundle.putByteArray(Intents.LIBRE_DATA_BUFFER, fullData); bundle.putLong(Intents.LIBRE_DATA_TIMESTAMP, timestamp); bundle.putString(Intents.LIBRE_SN, PersistentStore.getString("LibreSN")); bundle.putInt(Intents.LIBRE_RAW_ID, android.os.Process.myPid()); if(patchUid != null) { bundle.putByteArray(Intents.LIBRE_PATCH_UID_BUFFER, patchUid); } if(patchInfo != null) { bundle.putByteArray(Intents.LIBRE_PATCH_INFO_BUFFER, patchInfo); } intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); final String packages = PersistentStore.getString(CompatibleApps.EXTERNAL_ALG_PACKAGES); if (packages.length() > 0) { final String[] packagesE = packages.split(","); for (final String destination : packagesE) { if (destination.length() > 3) { intent.setPackage(destination); Log.d(TAG, "Sending to package: " + destination); xdrip.getAppContext().sendBroadcast(intent); } } } else { Log.d(TAG, "Sending to generic package"); xdrip.getAppContext().sendBroadcast(intent); } }