singletask activity for games

by rukiman » Fri, 17 Jul 2009 10:06:21 GMT


Sponsored Links
 I am completely confused with this. I am writing a game and there
should only be on instance of this game.

So far I have:
Splash screen activity
Menu activity
Game activity

The Game activity is the default activity and it will fire off an
intent with result to start the splash screen activity on the
onCreate.

The splash screen activity loads all the bitmaps required for the
game, once it is finished it will return the result to the game
activity which then knows all the bitmaps are finished.

The Game activity then will fire off an intent to show the Menu
acitivty.

Now since I only ever want one instance of my game. Should I make the
Splash screen, Menu and Game activity all singleTask?

If my Game activity is singleTask and I start a Menu activity that is
singleTask, is the Menu on a seperate task to the Game activity? How
can i make them all in one task?

I guess in my case whenever the Game activity gets an oncreate I can
safely assume I have to start from scratch i.e display splash screen
etc as I cannot assume the bitmaps are in memory.



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



singletask activity for games

by Dianne Hackborn » Fri, 17 Jul 2009 10:24:57 GMT


 Definitely don't make them singleTask.  Is there some behavior you are
seeing when using the default launch mode that you are trying to solve?  It
should work fine from what you describe.

As far as what you can assume...  receiving onCreate() just means that the
system need to make a new instance.  This may be because the user pressed
back to close your activity and is now restarting it, or they left it by
pressing home (but leaving it still running) and the system had to kill it
for its memory and the user has now returned to it.  You can distinguish
these with the savedState -- it will be non-null in the latter case.

As far as knowing whether your bitmaps are loaded -- that should probably be
done by just checking whether the variable(s) holding those bitmaps are
set.  I'd guess that you want to put these into a static global, so they
will only get reset when your process is killed and restarted.






-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

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


Sponsored Links


singletask activity for games

by rukiman » Fri, 17 Jul 2009 10:31:36 GMT


 hanks Dianne. I have changed the game so much regarding the
singleTask, singleInstance and confused myself in the process in terms
of the behaviour I was seeing :) So I'm trying to figure out what
meets my game's requirements before making any more confusing changes
lol.

If I don't make my splashscreen, menu and game activities to be
singleTask, doesn't that mean that when a user is playing my game,
presses the HOME key and clicks on the game icon, another new instance
of my game is created? I want to enforce only one instance of the
game, hence my reasoning for singleTask.

I had a look at the lunarlander, and I am assuming it does not enforce
a single instance as I cannot see any activity flags specified.


On Jul 17, 12:24pm, Dianne Hackborn <hack...@android.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



singletask activity for games

by Dianne Hackborn » Fri, 17 Jul 2009 10:43:20 GMT


 o, if the user selects your game from home while it is already running, it
will be brought to the foreground.

On Thu, Jul 16, 2009 at 7:31 PM, rukiman <ruksh...@optushome.com.au> wrote:



--
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails. All such
questions should be posted on public forums, where I and others can see and
answer them.

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



singletask activity for games

by rukiman » Fri, 17 Jul 2009 11:53:18 GMT


 h I see. Thanks, I understand now.

On Jul 17, 12:42pm, Dianne Hackborn <hack...@android.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. (OOT) Akhirnya ngeflash juga :)

Setelah pegang magic 2 Hari, Dan cocok sama cyanogen, Akhirnya memberanikan
diri upgrade ke versi terbaru. Sempat salah beberapa kali, tp akhirnya
sukses juga :)

Best Regards,
David Haryanto
*sent from my magic android phone
w/ CyanogenMod 4.2.15.1

-- 
"Indonesian Android Community [id-android]" 

2. HTC: Don鈥檛 put the Nexus One in y our hipster jeans

wah,...waspadalah..waspadalah :p





-- 
"Indonesian Android Community [id-android]" 

3. How do I start and stop GPS through program to save power?

4. i was beaten by AudioRecord :-(

5. about the operations on emulator

6. Buzz map -> Anggia Dyarini wants to share their location with you on Google Latitude

7. Google Nexus One Update ROM official dari Google