1

I have Arraylist private ArrayList<Movies> mMovies; of type Movies which is implemented as Parcelable defined in MainActivity.

mMovies contains list of movies around 20.

within MainActivity inside onCreateView() method I tried to pass the parcelable objects to another Activity called DetailActivity

Intent intent = new Intent(getActivity(), DetailActivity.class);
 intent.putExtra("MOVIES", movieList);
 startActivity(intent);

Using debugger i can see the movieList contains 20 rows.

This is how i tried to read parcelable objects which was passed through intents from MainActivity.

@Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 Bundle bundle = getActivity().getIntent().getExtras();
 mMovies = getActivity().getIntent().getParcelableExtra("MOVIES");
 }

While i try to see the mMovies value using debugger it shows null

enter image description here

asked Jul 13, 2015 at 14:55
2

3 Answers 3

2

Use putParcelable("MOVIES",mMovies); and getParcelableArrayListExtra("MOVIES") instead. How can I make my custom objects Parcelable? may provide some more insight.

answered Jul 13, 2015 at 15:04
Sign up to request clarification or add additional context in comments.

Comments

1

First, you put to extras list, but trying to get a Movie onject, use getParcelableArrayList()

Second, check out Parcelable implementation (and make sure you call right consctructor in CREATOR)

answered Jul 13, 2015 at 15:05

Comments

-1

My suggestion is exporting the Movies class to Json String as in: Android- create JSON Array and JSON Object Then, passing it as String from one Intent to the second

answered Jul 13, 2015 at 14:58

2 Comments

How do you suggest OP serializes the Movies class to JSON?
My suggestion is exporting the Movies class to Json String as: stackoverflow.com/questions/17810044/… Then, passing it as String from one Intent to the second

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.