我需要初始化 AppStateClient 以使用 Cloud 来保存和加载数据。我接下来做:
public Constructor() {
(1) private GameHelper aHelper = new GameHelper(this);
(2) aHelper.setup(this, GameHelper.CLIENT_APPSTATE | GameHelper.CLIENT_GAMES);
(3) private AppStateClient mHelper = aHelper.getAppStateClient();
}
但在第二个字符串中,我总是得到 NullPointerException。在 Goggle 的 GameHelper 类中,它崩溃:
mGamesClient = new GamesClient.Builder(getContext(), this, this)
.setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL)
.setScopes(mScopes)
.create();
and on:
mAppStateClient = new AppStateClient.Builder(getContext(), this, this)
.setScopes(mScopes)
.create();
我做错了什么?
我在我的应用程序中也用于成就和排行榜的 aHelper 变量,一切正常。