[mono-android] Being driven insane....

Paul F. Johnson paul at all-the-johnsons.co.uk
Sun Nov 27 12:49:01 EST 2011


Hi,

> >> 	StringWriter o = new StringWriter();
> >> 	x.Serialize (o, p);
> > 
> > Then just pass using PutExtra(string, string)?
> 
> Use o.ToString(), yeah:
> 
> 	b.PutExtra ("my.name", o.ToString ());

Sorry for the delay - work has been getting on top of things Android
related!

This is what I have so far

[Serializable]
public class common 
{
   // variables
}

I then have in my main activity class

public class AndroidTimeOfDeath : TabActivity
{
  common data = new common();
  XmlSerializer x = new XmlSerializer(data.GetType());
  StringWriter o = new StringWriter();
  x.Serialize(o, data);
  // set up things
  intent = new Intent(this, typeof(StateFound)); // one of the tabs
  intent.AddFlags(ActivityFlags.NewTask);
  intent.PutExtra("data", o.ToString());
  // rinse and repeat for the other tabs - each has the same PutExtra
}

Two little problems. The first is that the XmlSerializer is giving me a

System.InvalidOperatorException: (then nothing) error

The second comes from the deserialization of the extra put in - how do I
read it out? Is it passed in Bundle bundle (and if so, how?)

Currently my tabclass has this

public StateFound : Activity, iTabs
{
  common data;
  protected override void OnCreate(Bundle bundle)
  {
    base.Create(bundle);
    SetContentView(Resource.Layout.conditions);
    // set up spinner and other widgets
    XmlSerializer t = new XmlSerializer(typeof(common));
    // data = (common)t.Deserialize("data");  - doesn't work
  }
}

The deserialize won't work as I'm not sure how PutExtra works or where
it puts things in the first place!

Thanks again

Paul

-- 
Vertraue mir, ich weiss, was ich mache...



More information about the Monodroid mailing list