Skip to content Skip to sidebar Skip to footer

Updating Player Score In An Android Game

After updating the adt and having eclipse act a little more stable. I decided the next logical step would be adding a score system to my pong game. There is not collision detecti

Solution 1:

There's a few approaches you can use here:

  1. Use AsyncTask for the background processing
  2. Create a Handler in the GUI (main) thread, and post Runnables or messages to it.
  3. Use Activity.runOnUiThread

If you're likely to port to another platform, using a Runnable makes sense, as with the right abstraction, you can use javax.microedition.lcdui.Display.callSerially on J2ME, or javax.swing.SwingUtilities.invokeLater on J2SE

Hope this helps,

Phil Lello

Solution 2:

Not sure if you have looked at Asynctask. http://developer.android.com/reference/android/os/AsyncTask.html

I have found this to be the best way of communication between UI thread and the non-UI thread.

Post a Comment for "Updating Player Score In An Android Game"