問題描述
Android遊戲客戶端,Fragment上未顯示成就解鎖彈出窗口 (Android Game Client, Achievement unlock popup not shown over the Fragment)
我正在註冊彈出視圖如下:
GamesClient gamesClient = Games.getGamesClient(activity, googleSignInAccount);
gamesClient.setViewForPopups(getWindow().getDecorView().findViewById(android.R.id.content));
在主活動中,但是當從全屏片段對話框中解鎖成就時,沒有顯示彈出窗口,但在活動中,它顯示正確。
請幫助在片段上顯示彈出窗口。
我試圖從片段中註冊彈出視圖但沒有任何反應。
參考解法
方法 1:
Just do nothing and delete your setViewForPopups
call. It is not necessary.
方法 2:
try this
<FrameLayout
android:id="@+id/container_pop_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_marginTop="16dp" />
GamesClient gamesClient = Games.getGamesClient(MainActivity.this,
GoogleSignIn.getLastSignedInAccount(this));
gamesClient.setViewForPopups(findViewById(R.id.container_pop_up));
Games.getAchievementsClient(this, GoogleSignIn.getLastSignedInAccount(this))
.unlock(getString(R.string.achievement_example));
(by jitain sharma、MrStahlfelge、Ugur Gul)