Google Play Games popup not showing

I will unlock the achievement using this simple method from the docs developers:

Games.Achievements.unlock(getApiClient(), "my_achievement_id"); 

Achievement is unlocked, but a popup does not appear. There are also no pop-ups when logging into Google Play Games.

+5
source share
2 answers

I struggled with this for a while, so I decided to share it with stackoverflow. I described a simple fix for this issue on my development blog .

Here is the short version:

Just add a view to the layouts you want to display, for example:

 <FrameLayout android:id="@+id/gps_popup" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="20dp" /> 

When your layout is ready, you must execute it inside your activity or fragment:

 Games.setViewForPopups(getApiClient(), findViewById(R.id.gps_popup)); 

You must be sure that your GoogleApiClient is connected, although otherwise your application will fail.

+9
source
 <FrameLayout android:id="@+id/gps_popup" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="20dp" /> 

The same is in the answer of Jacek Quetia

 GamesClient gamesClient = Games.getGamesClient(MainActivity.this, GoogleSignIn.getLastSignedInAccount(context)); gamesClient.setViewForPopups(findViewById(R.id.gps_popup)); 

This has changed because setViewForPopups with 2 parameters is deprecated.

+1
source

Source: https://habr.com/ru/post/1205131/


All Articles