I'm trying to add a leaderboard in a game using Google Play Game Services.
Classes in which I display leaderboard and submit score extend Screen from Framework, so I created that Screen extends BaseGameActivity, which is required to use Google Play Game Services.
I get this error when I start app:
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:197)
at android.os.Handler.<init>(Handler.java:111)
at android.app.Activity.<init>(Activity.java:784)
at android.support.v4.app.FragmentActivity.<init>(FragmentActivity.java:76)
at com.x.x.BaseGameActivity.<init>(BaseGameActivity.java:65)
at com.x.framework.Screen.<init>(Screen.java:8)
at com.x.x.LoadingScreen.<init>(LoadingScreen.java:11)
at com.x.x.SplashLoadingScreen.update(SplashLoadingScreen.java:19)
at com.x.framework.implementation.AndroidFastRenderView.run(AndroidFastRenderView.java:47)
at java.lang.Thread.run(Thread.java:841)
Part of code where error is pointing:
BaseGameActivity.java
...protected BaseGameActivity() {
super();
}...
Screen.java
...public Screen(Game game) {
this.game = game;
}...
LoadingScreen.java
...public LoadingScreen(Game game) {
super(game);
}...
SplashLoadingScreen.java
...game.setScreen(new LoadingScreen(game));...
AndroidFastRenderView.java
...game.getCurrentScreen().update(deltaTime);...
Does anyone know how to fix this?