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


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. OpenGL 2D Game Framework

I've been working on a game framework for a little while, and while
its far from perfect, I've put the current version online.

To be honest, I haven't used much OpenGL in the past. Before last week
I had never tried using it.
If anyone would like to take a look, please do, I'd appreciate all the
help possible on speeding it up.
There are many features I have in mind and am planning at the minute,
but so far it supports:

# Texture and Sprite management
# Text, using TTF fonts
# Organised layers
# Two audio management classes, one optimized for music, the other for
sound effects
# Sprite dynamics (acceleration, terminal velocity, collisions)
# Animation
# Handlers to manage events fired through movement, animation, screen
touches, accelerometer input, device shaking and collisions
# Several minor features aimed at speeding development, such as screen
settings and vibration

The code is at

Again, I'd very much appreciate advice or help with any bugs you can
see, thanks.


2. coarse versus fine location provider

The MapView demo application sets the ACCESS_COARSE_LOCATION
permission for wifi or cell location.  Should a MapView activity also
set the ACCESS_FINE_LOCATION permission to enable GPS location
providers or is that permission also implied by setting

If both permissions are set and both settings are enabled will MapView
prefer the fine (over the coarse) location provider? And will MapView
sense a change in the availability of GPS?

In typical devices are the two settings enabled or disabled by default
(factory setting)?


3. Virtual touch area for an ImageButton

4. pendingIntent vs. Intent for Saurabh Sinha

5. Suggestion for Google team to improve Android Market

6. Booting the target with boot.img generated by Android

7. Mobile offline gmail web app on Android does not work for me!