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. getStreamVolume() returns 0 intermittently

We have an app that plays and records audio using AudioRecord and
AudioTrack, and also uses the 2.2 requestAudioFocus() API for audio
ducking.

We also use the AudioManager.getStreamVolume() call to determine if
the user has their volume control all the way down (as sometimes
happens) and to issue a warning.

Sometimes when recording, playback, and audio focusing is all going on
at the same time or in quick succession, this function returns 0. We
reproduce this via quick repeated presses of the Record button on our
app HeyTell v1.0.7 (it happens one out of about 5 times on a Motorola
Droid).


-- 

2. path appearing twice on map canvas

hi all,

I have a Main_Overlay class that extends Overlay.

I added This overlay to the mapview and override the Draw method as of
below:

        public void draw(android.graphics.Canvas canvas, MapView mapView,
boolean shadow )
        {
                 mPath = new Path();
         mPath.moveTo(0, -240);
         mPath.lineTo(-50, -100);
         mPath.lineTo(0, -150);
         mPath.lineTo(50, -100);
         mPath.close();

        Paint paint2 = new Paint();
        paint2.setStyle(Paint.Style.FILL);
        paint2.setAlpha(80);


        mPaint.setAntiAlias(true);
        mPaint.setColor(Color.RED);
        mPaint.setStyle(Paint.Style.FILL);
        mPaint.setAlpha(40);

        int w = canvas.getWidth();
        int h = canvas.getHeight();
        int cx = w / 2;
        int cy = h / 2;

        canvas.translate(cx, cy);

        canvas.drawPath(mPath, mPaint);

        }



However, the path is shown twice on the map canvas. One near the 0,0.
The other is at the bottom right hand corner.

When i draw it on normal canvas, only one path is shown.

Can Someone please advise?

Thanks!
Bryan

-- 

3. Eclipse Helios running SLOW

4. Eliminate cache or create size options

5. How to disable any android application.

6. Spinner Disable/Invisible And Auto Adjust the Other widgets Under the invisible/diabled one

7. Problem with own permissions