I created a static class that has a property call serialNumber.  I make
the call and just stick the serial number into the static class.  That
shouldn't be an issue, there's not issues with static classes are there?

Thanks

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Jonathan Pryor
Sent: Tuesday, July 26, 2011 11:00 AM
To: Discussions related to Mono for Android
Subject: Re: [mono-android] ID

On Jul 26, 2011, at 10:56 AM, Tim Kelly wrote:
> Ok, I'll look at that.  I called it when the application starts and
> stuck it in a static class for now.  Thanks, I'll look at passing it.

DO NOT stick an Activity into a static variable -- that way leads to
memory leaks.

If you need a static Context instance, stick an Android.App.Application
into a static varaible, e.g. via the Context.ApplicationContext instance
property:

        SomeStaticContext = this.ApplicationContext;

Alternatively you can use a custom Application and the [Application]
custom attribute to store a static Context:

        [Application]
        class MyApplication : Application {
                public MyApplication(IntPtr handle)
                        : base (handle);
                {
                        Context = this;
                }

                public static Context Context;
        }

 - Jon

_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to