Reputation: 197
I would like to pass a class reference to intent in order to have the instance of my class inside the Activity loaded. Please, consider I wrote "reference" to class, so it should not be another instance. Following all instruction I found I'm able to pass a class but it finally is another instance.
intent.putExtra("idletime", idle);
idle is my class I would like to pass as reference. and where I'm getting it:
idle_ = getIntent().getParcelableExtra("idletime");
but it seems that the reference is for a new instance of my class and not the same class instance I tried to pass.
this is the class definition but I think is not so important:
public class idletime extends AsyncTask<Object, Integer, Boolean> implements Parcelable {}
Something wrong?
Upvotes: 0
Views: 1732
Reputation: 49976
but it seems that the reference is for a new instance of my class and not the same class instance I tried to pass.
that is a correct behaviour, putExtra
will convert your class to binary form (serialize), then getParcelableExtra
will deserialize your class from binary form and this way create a new instance.
Upvotes: 3