Struggling with Activity/View framework

by Leigh McRae » Wed, 05 May 2010 04:07:34 GMT


Sponsored Links
 I am hoping that someone can help me out with my port to Android.  My 
game has abstracted out a few services and a couple of screens.  There 
services are fine but I have an options screen that needs to be 
implemented using native UI.


From reading the docs, I gather that I should be using an Activity 
paired with a View for the screen.  The problem is that showing a screen 
forces my Activity to be killed.  I tried to implement the options 
screen using a dialog but then I am restricted from using another 
dialog, for feedback, in the screen.


The whole life cycle of an Activity is really a ball breaker.  Most 
games load everything they need at startup and never allocate again.  So 
having a game save it's full state, not just save game, is a real 
challenge.  When you add in OpenGL, you pretty much have to keep a 
backing store of all the textures.


What is one to do?

--
Leigh McRae
www.lonedwarfgames.com

--



Struggling with Activity/View framework

by Bob Kerns » Fri, 07 May 2010 23:34:14 GMT


 The Activity may be killed, but the Application will not be. You can
hold onto state there.

However, it would be best to carefully study the lifecycle and look to
minimize how much information you keep there, and ALLOW information to
be discarded (or selected information to be kept) when the activity
that needs it is killed.

Note that simply starting a new activity does NOT guarantee the
previous activity is killed, it only allows for it

All the tools you need are there for information to persist with the
appropriate lifetime.

You should also consider persisting state in a database, preferences
object, or file, rather than retaining it in memory. There's tradeoffs
between memory usage and the cost of reloading data, but reducing
memory usage is important in this environment.



>


Sponsored Links


Other Threads

1. A blog about Android application development and development tools

Hello Shane, has Masa been updated for Android 1.5?

Thanks

Fred Grott
http://mobilebytes.wordpress.com







--~--~---------~--~----~------------~-------~--~----~

2. Turn off GPF for Google Map programmatically

Hi,
I am writing an Android application that invokes the built-in Google
Map using Intent.  My code looks like:

        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:
47.545992,-122.059613?zoom=15"));
        startActivity(intent);

When Google Map starts, however, GPS is on all the time.  Since I
normally shows places other than where I am located I would like to
turn off GPS for this session to save battery.  Does anybody know a
way to do this programmatically?

Thanks,
Wenzhong

--~--~---------~--~----~------------~-------~--~----~

3. WifiInfo object contains out of date info

4. File created with MODE_WORLD_WRITABLE mode could be accessed directly, but not through content provider.

5. A blog about Android application development and development tools

6. catching out of memory errors

7. android 1.5 to google maps API