View Single Post

Default 

November 1st, 2012, 02:50
Originally Posted by QuestLord View Post
got so excited I forgot to give valuable(yeah right) commentary.



I wouldn't worry about that. Every game will have its strength and weaknesses. The more that are out there the better. Also nothing is preventing you from going back and doing more. You already got me on the resolution! And probably other things I will just stay quiet about before launch.



That is an excellent plan to build up a fan base. Players like this a lot because it really helps them feel involved. Count me in as a supporter.
that's very true. as it is you are doing things on yours I kind of wish I had done - particularly animation. Anyway, you have any issues porting it over send me a PM. I'm finding out a lot of things the hard way. For instance…

…Just managed to get the background music to turn off when exiting the game (hitting home or running another app) by finally figuring how bound services work and implementing the correct methods. The the service connection Toasts stopped firing which means to me they actually don't fire unless a service is started and not bound. That's interesting. I'll have to file that in the back of my head.

There was a slight problem with it crashing but I realized right away that the service was trying to unbind twice. Can't unbind something that is no longer bound. A simple fix was easy - just wrap all the unbind calls in a boolean flag.

if(mBounded == true) {
unbindService(svc);
mBounded == false;
}


Just when I thought I got it licked I hit the power button on the device but the music kept playing. Argh.

A bit of research found me this:

http://thinkandroid.wordpress.com/20…en-on-intents/

which seems like a lot of code to do one silly thing (that the other code should have taken care of) but I managed to implement it. It is very simply.

And it works for about 5 minutes. Grr!

I think what is happening is some internal call to come out of the screen saver is happening (which it doesn't actually) and onResume is kicking in. This may be why someone on that link says that onPause is borqued.

In fact both onPause and onStop events seem to get called when I hit home or start a new Activity. Seems redundant to me.

I might try implementing the code in the Service code itself. This way every Activity doesn't have to have their own implementation of it. (Code example shows it for onStart and onCreate of a service. I'll have to test if it can bind when resuming - getting the onCreate to do that would likely cause a service to bind to itself and not the needed Activity).



I should note that memory use has increase 4 or 5x with the added music. I've been warned bound services are prone to memory leaks and I am curious if this is what is going on.

I'm getting a lot of "MediaPlayer finalized without being released" warnings but they appear to mostly come from the sound effects which don't call the service. I added release code but that seems to a) get rid of the sound before you get to hear it; b) not stop the warnings.

A little googling shows that some of it may due to multiple calls to the MediaPlayer - I wonder if the background music service still running is the cause. If it is I'll just have to suppress the warning because this is the functionality I want.

Edit: its sloppy but I think I can prevent the onResume audio bug by requiring the player to touch the screen when the game comes out of hibernation.

Developer of The Wizard's Grave Android game. Discussion Thread:
http://www.rpgwatch.com/forums/showthread.php?t=22520
Last edited by Lucky Day; November 1st, 2012 at 03:16.
Lucky Day is offline

Lucky Day

Lucky Day's Avatar
Daywatch

#47

Join Date: Oct 2006
Location: The Uncanny Valley
Posts: 3,188