[mono-android] Deserialize from Intent.GetStringExtra issue

nodoid paul at all-the-johnsons.co.uk
Tue Nov 29 10:03:24 EST 2011


Hi,

I'm slowly getting there (which is always good).

Serializing my class and passing it to other classes seems to be working.

Unfortunately at the other end, things aren't as good - I'm getting a null
exception.

        common data;

        public void deserialize()
        {
            System.Xml.Serialization.XmlSerializer t = new
System.Xml.Serialization.XmlSerializer(typeof(common));
            StringReader reader = new
StringReader(Intent.GetStringExtra("mydata"));
            data = (common)t.Deserialize(reader);
        }

This should be enough to deserialize and assign to data.

The serialize code looks like this

            common data = new common();
            //
            XmlSerializer x = new XmlSerializer(typeof(common));
            StringWriter o = new
StringWriter(System.Globalization.CultureInfo.InvariantCulture);
            x.Serialize(o, data);
            intent.PutExtra("mydata", o.ToString());

I'm assuming that I've used PutExtra correctly and that "mydata" is the
token I need to pull in the deserialize step.

Help!!!! I'd like to see the back of this app now ;)

Paul



--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/Deserialize-from-Intent-GetStringExtra-issue-tp5032637p5032637.html
Sent from the Mono for Android mailing list archive at Nabble.com.


More information about the Monodroid mailing list