Adding Objects to a new Intent

Put your problem here if it does not fit any of the other categories.

Adding Objects to a new Intent

Postby Txorl » Sun Nov 16, 2008 9:57 pm

Hello

I am trying to send an Activity Object(which is Parcelable) when i am starting a new Intent. Therefore i put the Parcelable Object into a bundle and add the bundle to the Intent.
Then i get the Contoller Object in the VideoAssortment Class via
"controller = (Controller)savedInstanceState.getParcelable("key");"

Example:

Class controller implements Parcelable{

public void startAssortment()
{

Intent temp = new Intent(Controller.this.getApplication(), VideoAssortment.class);
Bundle b = new Bundle();
b.putParcelable("key", this);
temp.putExtras(b);
startActivity(temp);

}
}

public class VideoAssortment extends ListActivity {
private Controller controller;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try
{
controller = (Controller)savedInstanceState.getParcelable("key");
controller.print("Hello");
}
catch (Exception e)
{}
}
}

Does anybody know why this does not work? :?

Thanks in advance
Txorl
Junior Developer
Junior Developer
 
Posts: 16
Joined: Wed Sep 17, 2008 3:12 pm

Top

Postby MrSnowflake » Sun Nov 16, 2008 11:50 pm

Shouldn't you "inflate" and "deflate" the Parcable manually?
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Parcelable

Postby Txorl » Mon Nov 17, 2008 12:19 pm

@MrSnowflake: What exactly do you mean? How would you inflate the Parcable so that i can send that object with an intent?
Txorl
Junior Developer
Junior Developer
 
Posts: 16
Joined: Wed Sep 17, 2008 3:12 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 23 guests