[Monodroid] How to load Assets outside of an Activity?

Mike Kestner mkestner at novell.com
Tue Mar 1 10:25:22 EST 2011


On Tue, 2011-03-01 at 17:11 +0200, Amir Waldman wrote:
> That can't be good... What if you were in the middle of editing data? The
> main activity (marked with: MainLauncher = true) holds the entire state of
> the application. How can it kill and recreate itself?

OnPause/OnResume.  Your activity needs to know how to reload itself.
This includes the user jumping to other apps and potentially coming back
to your activity at a later time.  You activity can get blown away at
any time for resource issues, etc...

You many want to take a look at:

http://developer.android.com/guide/topics/fundamentals/activities.html

There's a fairly extension discussion of lifecycle on that page.

> Is there an easier way to instantly get a reference to Context? All I want
> is to load an Asset using external code without worrying about it too much.

Where are you doing this?  "External code" is a bit vague.  If it's in a
view in response to an event or listener callback, View.Context will
give you the current context.  

Mike



More information about the Monodroid mailing list