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 8240677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:34:13+00:00 2026-06-07T20:34:13+00:00

I have got odd problem while sending intent with parcelable object. This object has

  • 0

I have got odd problem while sending intent with parcelable object. This object has got one String array. Using this answer How to send an object from one Android Activity to another using Intents? I have created first my object as parcelable and then send it. This is the fragment of my code:

    public class MyObject implements Parcelable{

    private String _title = null;
    private String[] _genre;
    private int _time = 0;
    private String _disc = null;

    private static final String TAG = "MyObject";

    public MyObject (String title, String[] genre, int time, String disc) {
        _title = title;
        _genre = genre;
        _time = time;
        _disc = disc;
    }



    public MyObject(Parcel source) {
            /*
             * Reconstruct from the Parcel
             */
            Log.v(TAG, "ParcelData(Parcel source): time to put back parcel data");
            _title = source.readString();
            try{
                source.readStringArray(_genre);
            }catch(Exception e){
                Log.e(TAG,e.toString());
            }
        _time = source.readInt();
        _disc = source.readString();
    }

    /*... Getters and setters and other stuff...*/

    @Override
    public int describeContents() {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        Log.v(TAG, "writeToParcel..."+ flags);
        dest.writeString(_title);
        dest.writeStringArray(_genre);
        dest.writeInt(_time);
        dest.writeString(_disc);
        Log.i(TAG,_genre[0]);
    }

    // this is used to regenerate your object. All Parcelables must have a CREATOR that implements these two methods
    public static final Parcelable.Creator<MyObject> CREATOR = new Parcelable.Creator<MyObject>() {
        public MyObject createFromParcel(Parcel in) {
            return new MyObject(in);
        }

        public MyObject[] newArray(int size) {
            return new MyObject[size];
        }
    };
}

Sending seems ok.

Intent displayInfo = new Intent(getApplicationContext(), MovieInfo.class);
                    displayInfo.putExtra(OBJECT, mySQLiteAdapter.getEntry(idSet));
                    startActivity(displayInfo);

However, when I am trying to get this data

Intent intent = getIntent();
        myParcel = (MyObject) intent.getParcelableExtra(FBM2Activity.OBJECT);

I am getting NullPointerException from readStringArray. Does anyone know where I can have got mistake?

  • 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-07T20:34:15+00:00Added an answer on June 7, 2026 at 8:34 pm

    Use _genre = source.createStringArray().

    The reasoning behind this is that readStringArray(String[] val) expects val to be a String[] that has already been created with the correct number of array elements. The way you are doing it, _genre is null when you call source.readStringArray(_genre).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have odd problem: After starting server I got this error: undefined local variable
I have an odd problem with mapping in Vim. I am using an Azerty
This might sound like an odd scenario, but I've got two forms on one
I have got a strange compile error while using condition operator. a,b are int
Hia, I got a somewhat odd problem. Im using two managed Classes that relate
I've got an odd problem here. Basically I have a TextView with no default
I've got an odd problem with a WPF Calendar control. I have modified the
I have got this code: function init(){ if (typeof window.jQuery !== 'function') { var
I have got two pages. example.com/php.com and example.com. I use this function to set
Ive just built a website for a client, and Ive got an odd problem

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.