Java Code Examples for android.os.Bundle.putByteArray()

The following are Jave code examples for showing how to use putByteArray() of the android.os.Bundle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ZxingScanner   File: DecodeHandler.java   View Source Code Vote up 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());
    bundle.putFloat(DecodeThread.BARCODE_SCALED_FACTOR, (float) width / source.getWidth());
}
 
Example 2
Project: mDL-ILP   File: ViewLicenseActivity.java   View Source Code Vote up 5 votes
@OnClick(R.id.license_image)
void licensePressed() {

    final Intent intent = new Intent(this, PictureZoomActivity.class);
    final Bundle extras = new Bundle();
    extras.putByteArray("picture", licence.getPhoto());
    intent.putExtras(extras);

    ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, headshot, "zoom");
    startActivity(intent, options.toBundle());
}
 
Example 3
Project: letv   File: ImageActivity.java   View Source Code Vote up 5 votes
public void setAvator(Bitmap bitmap, IUiListener iUiListener) {
    Bundle composeCGIParams = composeCGIParams();
    OutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    bitmap.compress(CompressFormat.JPEG, 40, byteArrayOutputStream);
    byte[] toByteArray = byteArrayOutputStream.toByteArray();
    bitmap.recycle();
    IRequestListener tempRequestListener = new TempRequestListener(iUiListener);
    composeCGIParams.putByteArray(SocialConstants.PARAM_AVATAR_URI, toByteArray);
    HttpUtils.requestAsync(this.mToken, Global.getContext(), "user/set_user_face", composeCGIParams, "POST", tempRequestListener);
    d.a().a(this.mToken.getOpenId(), this.mToken.getAppId(), Constants.VIA_SET_AVATAR_SUCCEED, "12", "19", "0");
}
 
Example 4
Project: mesh-core-on-android   File: MeshService.java   View Source Code Vote up 5 votes
public void onNewDevice(short devAddr, byte[] uuid) {
    Message msg = new Message();
    Bundle bundle = new Bundle();
    bundle.putByte(MESH_EVT_MSG_PAR_KEY_EVENT, MESH_EVENT_ON_NEW_DEVICE);
    bundle.putShort(MESH_EVT_MSG_PAR_KEY_DEVADDR, devAddr);
    bundle.putByteArray(MESH_EVT_MSG_PAR_KEY_UUID, uuid);
    msg.setData(bundle);
    mEvtHdl.sendMessage(msg);
}
 
Example 5
Project: WearTools   File: WTBothway.java   View Source Code Vote up 5 votes
/**
 * 注册监听响应的msg.
 *
 * @param context        c
 * @param msgListenerKey listerId 用于在map中标识监听器
 * @param handler        用于回传响应的数据
 * @param sendBothwayId  发送时的BothwayId.
 */
private static void regResponseMsgListener(
        final Context context, final long msgListenerKey,
        @NonNull final Handler handler, @NonNull final byte[] sendBothwayId) {
    WTResponseMsgListener listener = new WTResponseMsgListener() {
        @Override
        public void onResponseMsgReceived(String path, byte[] data, byte[] bothwayId) {
            //判断与发送时的path是否对应,避免同时发送2个请求时响应混乱。
            if (!Arrays.equals(sendBothwayId, bothwayId)) return;

            //双向通讯响应path格式为:/RE/WTBothway/{nanoTime}/xxx
            Message msg = handler.obtainMessage(HANDLER_RECEIVE_RESPONSE);
            Bundle bundle = new Bundle();
            bundle.putByteArray("data", data);
            bundle.putString("path", path);
            msg.setData(bundle);
            handler.sendMessage(msg);
            if (msgListenerMap.get(msgListenerKey) != null) {
                WTLog.v(TAG, "Remove response msg listener.");
                WTRegister.removeMessageListener(context, msgListenerMap.get(msgListenerKey));
                msgListenerMap.remove(msgListenerKey);
            }
        }
    };
    WTLog.v(TAG, "Register response msg listener.");
    msgListenerMap.put(msgListenerKey, listener);
    WTRegister.addMessageListener(context, listener);
}
 
Example 6
Project: weex-3d-map   File: DecodeHandler.java   View Source Code Vote up 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());
  bundle.putFloat(DecodeThread.BARCODE_SCALED_FACTOR, (float) width / source.getWidth());
}
 
Example 7
Project: Nird2   File: ShareForumFragment.java   View Source Code Vote up 5 votes
public static ShareForumFragment newInstance(GroupId groupId) {
	Bundle args = new Bundle();
	args.putByteArray(GROUP_ID, groupId.getBytes());
	ShareForumFragment fragment = new ShareForumFragment();
	fragment.setArguments(args);
	return fragment;
}
 
Example 8
Project: androidscan   File: DecodeHandler.java   View Source Code Vote up 5 votes
/**
 * create thumbnail
 *
 * @param source
 * @param bundle
 */

private 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.RGB_565);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 50, out);
    bundle.putByteArray(DecodeThread.BARCODE_BITMAP, out.toByteArray());
}
 
Example 9
Project: Udacity_Sunshine   File: ItemChoiceManager.java   View Source Code Vote up 5 votes
public void onSaveInstanceState(Bundle outState) {
    Parcel outParcel = Parcel.obtain();
    outParcel.writeSparseBooleanArray(mCheckStates);
    final int numStates = mCheckedIdStates.size();
    outParcel.writeInt(numStates);
    for (int i=0; i<numStates; i++) {
        outParcel.writeLong(mCheckedIdStates.keyAt(i));
        outParcel.writeInt(mCheckedIdStates.valueAt(i));
    }
    byte[] states = outParcel.marshall();
    outState.putByteArray(SELECTED_ITEMS_KEY, states);
    outParcel.recycle();
}
 
Example 10
Project: Nird2   File: RevealContactsFragment.java   View Source Code Vote up 5 votes
public static RevealContactsFragment newInstance(GroupId groupId) {
	Bundle args = new Bundle();
	args.putByteArray(GROUP_ID, groupId.getBytes());
	RevealContactsFragment fragment = new RevealContactsFragment();
	fragment.setArguments(args);
	return fragment;
}
 
Example 11
Project: Nird2   File: ThreadListActivity.java   View Source Code Vote up 5 votes
@Override
protected void onSaveInstanceState(Bundle outState) {
	super.onSaveInstanceState(outState);
	ThreadItem replyItem = adapter.getHighlightedItem();
	if (replyItem != null) {
		outState.putByteArray(KEY_REPLY_ID, replyItem.getId().getBytes());
	}
}
 
Example 12
Project: Nird2   File: GroupInviteFragment.java   View Source Code Vote up 5 votes
public static GroupInviteFragment newInstance(GroupId groupId) {
	Bundle args = new Bundle();
	args.putByteArray(GROUP_ID, groupId.getBytes());
	GroupInviteFragment fragment = new GroupInviteFragment();
	fragment.setArguments(args);
	return fragment;
}
 
Example 13
Project: SmartButler   File: DecodeHandler.java   View Source Code Vote up 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 14
Project: LifeHelper   File: DecodeHandler.java   View Source Code Vote up 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
Project: Nird2   File: AddContactActivity.java   View Source Code Vote up 5 votes
@Override
public void onSaveInstanceState(Bundle state) {
	super.onSaveInstanceState(state);
	if (localAuthorId != null) {
		byte[] b = localAuthorId.getBytes();
		state.putByteArray("briar.LOCAL_AUTHOR_ID", b);
	}
	state.putInt("briar.LOCAL_CODE", localInvitationCode);
	state.putInt("briar.REMOTE_CODE", remoteInvitationCode);
	state.putBoolean("briar.FAILED", connectionFailed);
	state.putString("briar.CONTACT_NAME", contactName);
	if (task != null) state.putLong("briar.TASK_HANDLE", taskHandle);
}
 
Example 16
Project: okwallet   File: RequestCoinsFragment.java   View Source Code Vote up 4 votes
private void saveInstanceState(final Bundle outState) {
    outState.putByteArray("receive_address", address.getHash160());
}
 
Example 17
Project: boohee_v5.6   File: WXEmojiObject.java   View Source Code Vote up 4 votes
public void serialize(Bundle bundle) {
    bundle.putByteArray("_wxemojiobject_emojiData", this.emojiData);
    bundle.putString("_wxemojiobject_emojiPath", this.emojiPath);
}
 
Example 18
Project: MRouter   File: MainActivity.java   View Source Code Vote up 4 votes
public Bundle assembleBundle() {
    User user = new User();
    user.setAge(90);
    user.setGender(1);
    user.setName("kitty");

    Address address = new Address();
    address.setCity("HangZhou");
    address.setProvince("ZheJiang");

    Bundle extras = new Bundle();
    extras.putString("extra", "from extras");


    ArrayList<String> stringList = new ArrayList<>();
    stringList.add("Java");
    stringList.add("C#");
    stringList.add("Kotlin");

    ArrayList<String> stringArrayList = new ArrayList<>();
    stringArrayList.add("American");
    stringArrayList.add("China");
    stringArrayList.add("England");

    ArrayList<Integer> intArrayList = new ArrayList<>();
    intArrayList.add(100);
    intArrayList.add(101);
    intArrayList.add(102);

    ArrayList<Integer> intList = new ArrayList<>();
    intList.add(10011);
    intList.add(10111);
    intList.add(10211);

    ArrayList<Address> addressList = new ArrayList<>();
    addressList.add(new Address("JiangXi", "ShangRao", null));
    addressList.add(new Address("ZheJiang", "NingBo", null));

    Address[] addressArray = new Address[]{
            new Address("Beijing", "Beijing", null),
            new Address("Shanghai", "Shanghai", null),
            new Address("Guangzhou", "Guangzhou", null)
    };
    Bundle bundle = new Bundle();
    bundle.putSerializable("user", user);
    bundle.putParcelable("address", address);
    bundle.putParcelableArrayList("addressList", addressList);
    bundle.putParcelableArray("addressArray", addressArray);
    bundle.putString("param", "chiclaim");
    bundle.putStringArray("stringArray", new String[]{"a", "b", "c"});
    bundle.putStringArrayList("stringArrayList", stringList);
    bundle.putStringArrayList("stringList", stringArrayList);
    bundle.putByte("byte", (byte) 2);
    bundle.putByteArray("byteArray", new byte[]{1, 2, 3, 4, 5});
    bundle.putInt("age", 33);
    bundle.putIntArray("intArray", new int[]{10, 11, 12, 13});
    bundle.putIntegerArrayList("intList", intList);
    bundle.putIntegerArrayList("intArrayList", intArrayList);
    bundle.putChar("chara", 'c');
    bundle.putCharArray("charArray", "chiclaim".toCharArray());
    bundle.putShort("short", (short) 1000000);
    bundle.putShortArray("shortArray", new short[]{(short) 10.9, (short) 11.9});
    bundle.putDouble("double", 1200000);
    bundle.putDoubleArray("doubleArray", new double[]{1232, 9999, 8789, 3.1415926});
    bundle.putLong("long", 999999999);
    bundle.putLongArray("longArray", new long[]{1000, 2000, 3000});
    bundle.putFloat("float", 333);
    bundle.putFloatArray("floatArray", new float[]{12.9f, 234.9f});
    bundle.putBoolean("boolean", true);
    bundle.putBooleanArray("booleanArray", new boolean[]{true, false, true});

    return bundle;
}
 
Example 19
Project: Nird2   File: BlogFragment.java   View Source Code Vote up 3 votes
static BlogFragment newInstance(GroupId groupId) {

		BlogFragment f = new BlogFragment();

		Bundle bundle = new Bundle();
		bundle.putByteArray(GROUP_ID, groupId.getBytes());

		f.setArguments(bundle);
		return f;
	}
 
Example 20
Project: Lyra   File: ByteArrayCoder.java   View Source Code Vote up 2 votes
/**
 * Write a field's value into the saved state {@link Bundle}.
 *
 * @param state      {@link Bundle} used to save the state
 * @param key        key retrieved from {@code fieldDeclaringClass#fieldName}
 * @param fieldValue value of field
 */
@Override
public void serialize(@NonNull Bundle state, @NonNull String key, @NonNull byte[] fieldValue) {
    state.putByteArray(key, fieldValue);
}