How can we run code on an object instance before construction?

We can do it with initialization blocks. I find it actually a very interesting feature of java even though I would recommend to be very careful when using it. Indeed, initialization blocks might confuse people looking at your code especially if there is not only one and if it’s not placed close to the constructor.
So an . . . → Read More: How can we run code on an object instance before construction?

Different threads for different purposes

You want your android application to be responsive, so you have to “multithread” it. But actually, “twothreading” should be enough in many cases.
The main thread, the one on which the application started, can be used to wait for user input like touchscreen events. So whenever the user does something, the event is caught on the main . . . → Read More: Different threads for different purposes

Adding sound and music to an android game

It’ s pretty straight forward to add music and sound to an android application.

For music, I use the Mediaplayer class. For simple short sounds that I need at different stages in the application (transitions, selections, etc.) I use the SoundPool class. SoundPool enables to load short sound sequences directly in memory at the start of the application, sounds that can be used later on at any time in the application.
In Silhouette, I use a class with static members and methods. So the music player and the sounds are available during the whole game life cycle and they can be called from anywhere. It works pretty well.

Continue reading Adding sound and music to an android game