Issue
Why bundle has getParcelableArrayList
, getParcelable
methods; but
Intent
has only putParcelableArrayListExtra
method?
Can I transmit only object<T>
, not ArrayList
of one element?
Then, what is getParcelable
for?
Solution
Intent provides bunch of overloading putExtra() methods.
Suppose you have a class Foo implements Parcelable properly, to put it into Intent in an Activity:
Intent intent = new Intent(getBaseContext(), NextActivity.class);
Foo foo = new Foo();
intent.putExtra("foo ", foo);
startActivity(intent);
To get it from intent in another activity:
Foo foo = getIntent().getExtras().getParcelable("foo");
Answered By - yorkw
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.