I’m developing an android game that uses a surface view for representing the ui graphics. I need to implement a method to start another activity if the user touches a specific area.
for this i’m passing the main (foreground) activity’s current instance to the surface view
I can handle the touch easily but cannot start the activity from received instance.
**> if i call startActivity method from the received instance of the
current activity Exceptions occurs stating that its a call from non
ui-thread**
i’m using a class extended to surface view and passed to a thread which draws on its canvas
Is the SurfaceView within an activity?
If so, use
If you are not within an activity you really shouldn’t be starting other activities..
Also SurfaceView has a post and postDelayed methods which can be use to post Runnables on the UI thread.