I'm trying to launch an Intent from the render method in libgdx but I am getting a "Can't create handler inside thread that has not called Looper.prepare()" error.
I have implemented the Interface from here http://code.google.com/p/libgdx-users/wiki/IntegratingAndroidNativeUiElements3TierProjectSetup
I have used the Toast implementaion and that works okay.
This is my Android implementation
@Override
public void launchPlayerRoom() {
Intent intent = new Intent(appContext, RoomViewActivity.class);
intent.putExtras(selectPlayerRoom());
startActivity(intent);
}
and calling from Libgdx render
if (health_amount <= 0){
actionResolver.launchPlayerRoom();
}
The Intent needs to be called from render as it depends on a value that is decremented in render. I understand that the problem is calling a UI thread from a render thread(I think!) but I don't know how to solve it. I have tried from this post Can't create handler inside thread that has not called Looper.prepare()
@Override
public void launchPlayerRoom() {
final Intent intent = new Intent(appContext, RoomViewActivity.class);
intent.putExtras(selectPlayerRoom());
runOnUiThread(new Runnable() {
@Override
public void run() {
startActivity(intent);
}
});
But this makes no difference.
Any help would be most appreciated.