I have an activity which uses a surfaceview as its content view to draw some bitmaps and carry out animations, what is the best way to control starting a new round event to load a new set of bitmaps for the next round within this surfaceview thread or what is the best way to switch from a surfaceview thread, back to the main game activity after a round is done. What I have tried so far, below is a snippet from the surfaceview class where everything is drawn.
if(isCollided(i)){
if(imgList.indexOf(imgList.get(i)) == 0){
activity.runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(context, "Correct!", Toast.LENGTH_SHORT).show();
Intent i = new Intent(context, AnimeAction.class);
context.startActivity(i);
}});
}
You should not do this :
Instead try this :
As far as posting a new set of bitmaps is concerned, I have done it like this in my app :
And in the Activity’s
onResume()andonCreate():I learnt it from this video (and the subsequent one’s 1.28 -1.33) – http://youtube.com/watch?v=Z2YogvILjvo