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. Android Compilation Ends With Error 41.

Hi people, i tryed to google it but nothing help me..


This is the error.

r...@buch-desktop:~/mydroid# make
build/core/product_config.mk:261: WARNING: adding test OTA key
============================================
TARGET_PRODUCT=htc_dream
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=
============================================
build/core/Makefile:17: warning: overriding commands for target `out/
target/product/dream/system/etc/apns-conf.xml'
build/core/Makefile:17: warning: ignoring old commands for target `out/
target/product/dream/system/etc/apns-conf.xml'
build/core/Makefile:17: warning: overriding commands for target `out/
target/product/dream/system/etc/wifi/tiwlan.ini'
build/core/base_rules.mk:384: warning: ignoring old commands for
target `out/target/product/dream/system/etc/wifi/tiwlan.ini'
No private recovery resources for TARGET_DEVICE dream
make: execvp: /bin/bash: Lista degli argomenti troppo lunga
Compiling SDK Stubs: out/target/common/obj/JAVA_LIBRARIES/
android_stubs_current_intermediates/classes.jar
out/target/common/obj/JAVA_LIBRARIES/
android_stubs_current_intermediates/src/android/view/inputmethod/
MutableInputConnectionWrapper.java:5: cannot find symbol
symbol  : constructor InputConnectionWrapper
(android.view.inputmethod.InputConnection)
location: class android.view.inputmethod.InputConnectionWrapper
public  MutableInputConnectionWrapper
(android.view.inputmethod.InputConnection base) { super
((android.view.inputmethod.InputConnection)null); throw new
RuntimeException("Stub!"); }
 
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
make: *** [out/target/common/obj/JAVA_LIBRARIES/
android_stubs_current_intermediates/classes.jar] Error 41
r...@buch-desktop:~/mydroid#


Can't find a solution.


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

2. Error while launching the emulator

Hi all,

Sorry to ask this question if anyone has already done.

My issue is that while I am running the HelloWorld file, I get this error on
Eclipse:

[2009-06-11 16:10:30 - Emulator] emulator: ERROR: unknown virtual device
name: 'my_Avd'
[2009-06-11 16:10:30 - Emulator] emulator: could not find virtual device
named 'my_Avd'

I've read something on the web about where the emulator points to get the
avd but I do not reach to find how to solve the problem.

Thanks for your help, in advance.

Regards,
Flix

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

3. getNeighboringCellInfo Not working??

4. getNeighboringCellInfo() How to???

5. how to read rtsp streaming

6. How to disable automatic redirect handling by HttpClient in Android 1.5?

7. get accelerometer data at given freequencies