So I've been struggling with putting some values into a bundle in my overrided OnSaveInstanceState. I need so save some class objects on activity restart, meaning they have to be parcelable, which seem to be impossible to implement for Monodroid?
Source : http://docs.xamarin.com/android/about/limitations
What can i do to save these class objects in to the bundle without parcelable? I load data from a server, and I don't wish to do that again for example on a user rotation, which once again calls the OnCreate method. Therefore it would be nice to have them saved, which saves the server some pressure on occasional rotations and such.
Bundle is a container for named values of types standard for android (including Parcelable ), which is used to pass data between activies, fragments and other android app entites.
Parcelable and Bundle objects are intended to be used across process boundaries such as with IPC/Binder transactions, between activities with intents, and to store transient state across configuration changes.
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);
In simple terms Parcelable is used to send a whole object of a model class to another page. In your code this is in the model and it is storing int value size to Parcelable object to send and retrieve in other activity.
The originally accepted answer for this question, while true at the time it was answered, is no longer the case.
I had originally implemented the above suggestion and then later on through more searching found this:
http://dan.clarke.name/2012/09/implementing-iparcelable-in-mono-for-android/
The feature is now supported and the above link is a great resource on how to implement it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With