使用GameHelper而不使用BaseGameActivity的Google Play游戏服务

时间:2014-04-17 18:59:46

标签: java android

我想在Android游戏中添加排行榜。我想使用没有BaseGameActivity的GameHelper。我按照以下链接:

Using Game Helper Witout BaseGameActivity

在我的主要活动中,我已完成上述链接中所述的所有操作。 我在互联网上搜索了GameHelper的工作原理,但没有找到太多的信息或教程。

GameHelper mHelper;

@Override
public void onCreate(Bundle savedInstanceState) {
// create game helper with all APIs (Games, Plus, AppState):
mHelper = new GameHelper(this, GameHelper.CLIENT_ALL);

// enable debug logs (if applicable)
if (DEBUG_BUILD) {
    mHelper.enableDebugLog(true, "GameHelper");
}

GameHelperListener listener = new GameHelper.GameHelperListener() {
    @Override
    public void onSignInSucceeded() {
        // handle sign-in succeess
    }
    @Override
    public void onSignInFailed() {
        // handle sign-in failure (e.g. show Sign In button)
    }

};
mHelper.setup(listener);
}


    @Override
protected void onStart() {
    super.onStart();
    mHelper.onStart(this);
}

@Override
protected void onStop() {
    super.onStop();
    mHelper.onStop();
}

@Override
protected void onActivityResult(int request, int response, Intent data) {
    super.onActivityResult(request, response, data);
    mHelper.onActivityResult(request, response, data);
}

这是我提交分数的方式:

public void submitScore(long score){
    Games.Leaderboards.submitScore(mHelper.getApiClient(), LEADERBOARD_ID, score);
    startActivityForResult(Games.Leaderboards.getLeaderboardIntent(mHelper.getApiClient(), LEADERBOARD_ID), REQUEST_LEADERBOARD);
}

这是我得到的错误。

04-17 20:56:23.268: W/dalvikvm(1942): threadid=1: thread exiting with uncaught exception (group=0x40fdb2a0)
04-17 20:56:23.268: E/AndroidRuntime(1942): FATAL EXCEPTION: main
04-17 20:56:23.268: E/AndroidRuntime(1942): java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.
04-17 20:56:23.268: E/AndroidRuntime(1942):     at com.google.android.gms.internal.eh$h.b(Unknown Source)
04-17 20:56:23.268: E/AndroidRuntime(1942):     at com.google.android.gms.internal.eh$h.a(Unknown Source)
04-17 20:56:23.268: E/AndroidRuntime(1942):     at com.google.android.gms.internal.eh$b.ec(Unknown Source)
04-17 20:56:23.268: E/AndroidRuntime(1942):     at com.google.android.gms.internal.eh$a.handleMessage(Unknown Source)
04-17 20:56:23.268: E/AndroidRuntime(1942):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-17 20:56:23.268: E/AndroidRuntime(1942):     at android.os.Looper.loop(Looper.java:137)
04-17 20:56:23.268: E/AndroidRuntime(1942):     at android.app.ActivityThread.main(ActivityThread.java:4921)
04-17 20:56:23.268: E/AndroidRuntime(1942):     at java.lang.reflect.Method.invokeNative(Native Method)
04-17 20:56:23.268: E/AndroidRuntime(1942):     at java.lang.reflect.Method.invoke(Method.java:511)
04-17 20:56:23.268: E/AndroidRuntime(1942):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
04-17 20:56:23.268: E/AndroidRuntime(1942):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
04-17 20:56:23.268: E/AndroidRuntime(1942):     at dalvik.system.NativeStart.main(Native Method)
04-17 20:56:23.273: D/dalvikvm(1942): GC_CONCURRENT freed <1K, 10% free 12510K/13895K, paused 11ms+19ms, total 42ms

0 个答案:

没有答案