General task state detection & handling

by Grant » Thu, 14 Oct 2010 01:34:56 GMT

Sponsored Links
 In my current application (a game) I'm currently having problems
determining when to pause my audio. Pretty much the entire game runs
in a single Activity (basically a wrapper around some JNI code) so
changing between game states is irrelevant. My main problems come from
the key-lock screen and a 3rd party library which I use for leader-
boards and the like.

Previously I would pause/resume the audio whenever the appliction had
'onWindowFocusChanged' called which handled the key-lock screen as
expected. Unfortunately this had the side effect of causing
'AlertDialog' dialogs to cut out the audio when displayed.
Subsequently, I changed it to pause/resume audio in the 'onPause' and
'onResume' functions of the Activity. This works well except the sound
will continue to play when the key-lock screen is up. Is there any way
for me to detect when the key-lock screen gets displayed (apart from
constantly polling) and pause the sound when this occurs?

My other problem is that when I start the activity for the 3rd party
library (it actually starts it self after it establishes a network
connection), my audio stops playing (as the game's activity goes to
the background and gets "paused"). How can I detect when the entire
task/application goes to the background?



Other Threads

1. MediaPlayer stops playing when streaming over 3G on the Nexus One

Another small thing:  It doesn't matter whether the Nexus One is
sleeping or not.  I happens even though I set the device and screen to
never sleep.



2. Question about Button and SurfaceView


I am trying to use SurfaceView for an app. But I need to add buttons the
canvas as well. Not able to gather much from Android.developer site. Can
anybody post if they have done it or have some ideas ?

Karthik R
Graduate Student
Computer Science Department


3. Missing map!

4. Latitude lg error?

5. Dynamically extend the height of the ListView row background image?

6. media server interactions

7. SOLVED - WTA: Gmail Amplop Merah