Passing argument between Activities - null
I'm sending an object of my custom class which implements Serializable:
public class MyObject extends ParseObject implements Serializable {
The class contains atm one string and one ParseFile.
I'm trying to pass an object from one Activity to another.
private void editMyObject(MyObject myObject) {
Intent intent = new Intent(AActivity.this, BActivity.class);
intent.putExtra("MyObject", myObject);
Toast.makeText(getApplicationContext(), "OUT: "+myObject.getTitle(),
Toast.LENGTH_SHORT).show(); // here i get the content, proper string
startActivity(intent);
}
And in 'receiver' activity:
protected void onCreate(Bundle savedInstanceState) {
...
Intent intent = getIntent();
myObject = (MyObject)intent.getSerializableExtra("MyObject");
if (myObject != null) {
editText.setText(myObject.getTitle());
}
Toast.makeText(getApplicationContext(), "IN: "+myObject.getTitle(),
Toast.LENGTH_SHORT).show(); // here is null
}
What am i doing wrong..? I followed another questions on SOF but that
didn't help ;)
No comments:
Post a Comment