Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8912809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:18:04+00:00 2026-06-15T04:18:04+00:00

I knew that parcelable are hide something secret, but didn’t thought that i need

  • 0

I knew that parcelable are hide something secret, but didn’t thought that i need to know them, unitl now.

Here is the code i had before:

...
parcel.writeBooleanArray(new boolean[]{booleanValue1, booleanValue2, booleanValue3});
....

boolean[] booleans = new boolean[3];
in.readBooleanArray(booleans);
...

Somehow it stops working on many devices except my, so i can’t reproduce it. Then i decided to change it to:

        ...
    parcel.writeBooleanArray(new boolean[]{booleanValue1});
    parcel.writeBooleanArray(new boolean[]{booleanValue2});
    parcel.writeBooleanArray(new boolean[]{booleanValue3});
        ...

    boolean[] booleans1 = new boolean[1];
    boolean[] booleans2 = new boolean[1];
    boolean[] booleans3 = new boolean[1];
    in.readBooleanArray(booleans1);
    in.readBooleanArray(booleans2); // it crashes here
    in.readBooleanArray(booleans3);
        ....

Source code of Parcel:

public final void readBooleanArray(boolean[] val) {
    int N = readInt();
    if (N == val.length) {
        for (int i=0; i<N; i++) {
            val[i] = readInt() != 0;
        }
    } else {
        throw new RuntimeException("bad array lengths");
    }
}

LogCat errors:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my/com.my.activities.MyActivity}: java.lang.RuntimeException: bad array lengths
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
    at android.app.ActivityThread.access$600(ActivityThread.java:128)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4517)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: bad array lengths
    at android.os.Parcel.readBooleanArray(Parcel.java:619)

So my guess that i need to change the code to:

...
parcel.writeBooleanArray(new boolean[]{booleanValue1, booleanValue2, booleanValue3});
....

boolean[] booleans1 = new boolean[1];
boolean[] booleans2 = new boolean[1];
boolean[] booleans3 = new boolean[1];
in.readBooleanArray(booleans1);
in.readBooleanArray(booleans2);
in.readBooleanArray(booleans3);
....

But will it help?

Also what is the usage of Parcel.createBooleanArray() returns boolean[]; Maybe i need to create boolean array via this method and then use writeBooleanArray(boolean[])? But it doesn’t make sense to me… why it’s working on some devices and doesn’t on other…

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:18:06+00:00Added an answer on June 15, 2026 at 4:18 am

    Actually i found solution for my problem, but not answer in another question:

    Here is how can You work with booleans in Pracelable:

    .....
    // Write:
    out.writeByte((byte) (booleanValue ? 1 : 0));
    
    ....
    
    // Read:
    boolValue = in.readByte() == 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I knew that we have something like this in the regular expression syntax world.
Sometimes its the simple things you thought you knew that make your head buzzz....
I knew that java.util.Calendar class method getInstance() returns a GregorianCalendar but how could i
I knew that we can create child themes for wordpress. But i want to
I knew that we can set innodb as engine tables. But can we add
I want to know how to create multi-level games with cocos2d. I knew that
I need to implement a DockLayoutPanel in UiBinder. I knew that we can use
facebook has the facebook credit and I knew that they are testing on pay
When I wanted to get Android source code, I knew that I have to
What is Rhino.Python ? I came across it and also knew that it can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.