Fixing this is trickier than it sounds. Some games wait for onWindowFocusChanged() instead of onResume(), which works pretty well on Gingerbread. But on Honeycomb and higher, onWindowFocusChanged() is sent when certain foreground windows — like, ironically, the volume control display window — take focus. The result is that when the user changes the volume, all of the sound is muted. Not the developer’s original intent!
Waiting for onResume() and onFocusChanged() seems like a possible fix, and it works pretty well in a large number of cases. But even this approach has its Achilles’ heel. If the device falls asleep on its own, or if the user locks the phone and then immediately unlocks it, your app may not receive any focus changed messages at all.
This doesn't give me a lot of confidence in the framework decisions being made by the android team.
Wow, new low for Javascript non-fallbacks. That page has no scrollbar in my default setting (Opera with Javascript disabled) so the text is cut off mid way through the post.
Too short!
I was hoping for more tricks and tips.
I started learning Android programming by making a game. (http://developingthedream.blogspot.com/)
It's tricky to get things like multiple activities, dialog activities, efficient service communication.
Then of course, multiple displays and sizes. Also, different keyboard layouts, etc.
8 comments
[ 2.9 ms ] story [ 26.9 ms ] threadWaiting for onResume() and onFocusChanged() seems like a possible fix, and it works pretty well in a large number of cases. But even this approach has its Achilles’ heel. If the device falls asleep on its own, or if the user locks the phone and then immediately unlocks it, your app may not receive any focus changed messages at all.
This doesn't give me a lot of confidence in the framework decisions being made by the android team.
1. Pause playback when you receive onPause().
2. When you receive onResume():
2a. If you have previously received an onFocusChanged(false) message, wait for an onFocusChanged(true) message to arrive before resuming playback.
2b. If you have not previously received an onFocusChanged(false) message, then resume audio immediately.
3. Test thoroughly!
The documentation for onFocusChanged might be helpful for you: http://developer.android.com/reference/android/view/View.OnF...
In Firefox I was able to get scrolling by disabling the page style (View->Page Style->No Style). I'd imagine there's something similar in Opera.