Google Play Games achievement unlocked popup not showing

后端 未结 4 993
一生所求
一生所求 2020-12-06 06:43

I\'m unlocking achievement using this simple method from developers docs:

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

相关标签:
4条回答
  • 2020-12-06 07:02

    Had the same problem. I have solved it by adding icon to the achievement. I am not kidding, it is really strange but it started to work after that. Please note that I am talking about not published project, I was just testing my app and wondering what is going on.

    0 讨论(0)
  • 2020-12-06 07:05
    <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" />
    

    This is the same in Jacek Kwiecień answer

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

    This changed because setViewForPopups with 2 parameters is deprecated.

    0 讨论(0)
  • 2020-12-06 07:05

    Jacek and user3782779 answers didn't work for me, I had to do the following:

    GamesClient gamesClient = Games.getGamesClient(this, GoogleSignIn.getLastSignedInAccount(this));
    gamesClient.setViewForPopups(findViewById(android.R.id.content));
    gamesClient.setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
    
    0 讨论(0)
  • 2020-12-06 07:25

    Just add a view to the layouts you want to display achievements on like this:

    <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 you have your layout ready you neet to execute this inside your Activity or Fragment:

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

    You have to be sure, that your GoogleApiClient is connected though, otherwise your app will crash.

    0 讨论(0)
提交回复
热议问题