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. Windows Driver for Nexus One so that Adb can detect the phone

Thnx, got it working.

> Android App Developer Training:

2. set imageView

hi all,

I have a imageView1 and imageView2,
then i want to set imageView1 to imageView2,
but use the following API will not do this,
such as:
setBackgroundResource(int resource id)
setBackgroundDrawable(drawable d)
setImageBitmap(Bitmap b)
setImageDrawable(drawable d)

so how can I do?


3. Suggestion: Math floating point library for Android

4. Elliptic Curve cryptography in Androi

5. Help me!! The fb0 no space left on device..

6. Problem reading from files when using within service.

7. change the imageview dynamically in the listview