Google Play成就弹出窗口未显示

时间:2018-09-04 17:46:48

标签: android google-play-games

我对Google Play库很陌生,无法找出原因,为什么在我的应用程序中解锁成就时没有收到消息。

这是我目前使用的代码

final AppCompatActivity activity = this;

        Games.getGamesClient(this, acc).setViewForPopups(findViewById(R.id.popupBar)).addOnSuccessListener(new OnSuccessListener<Void>() {
            @Override
            public void onSuccess(Void aVoid) {
                AchievementsClient aClient = Games.getAchievementsClient(activity, acc);
                aClient.unlock(getString(R.string.achievement_game_started));
                Toast.makeText(activity, "Got Achievement", Toast.LENGTH_SHORT).show();
            }
        });

此代码在onActivityResult函数内部使用,此函数随后被调用

GoogleSignInClient signInClient = GoogleSignIn.getClient(this, GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
Intent intent = signInClient.getSignInIntent();
startActivityForResult(intent, RC_SIGN_IN);

我也尝试过手动单击按钮来解锁成就,但仍然没有弹出窗口。 R.id.popupBar的布局文件位于layouts内部,如下所示:

<FrameLayout android:id="@+id/popupBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
xmlns:android="http://schemas.android.com/apk/res/android" />

预先感谢

0 个答案:

没有答案
相关问题