2

I am having issues in understanding Google Developers Guides:

Google Developers GUIDE Add Leaderboards

I have created a game using LibGDX, so I have a Core module and Android Module. In Android Module I only have AndroidLauncher Class which extends AndroidApplication.

public class AndroidLauncher extends AndroidApplication implements ActionResolver, GoogleApiClient.OnConnectionFailedListener{

    ActionResolverAndroid actionResolverAndroid;
    @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        actionResolverAndroid = new ActionResolverAndroid(this);
        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
        initialize(new PepeAdventures(actionResolverAndroid), config);
    }

I have created another class in Android module called ActionResolverAndroid.

public class ActionResolverAndroid implements ActionResolver {

    Handler handler;
    Context context;
    GoogleApiClient client;

    public ActionResolverAndroid(Context context){
        handler = new Handler();
        this.context = context;

        client = new GoogleApiClient.Builder(context)
                 .addApi(Drive.API)
                .addScope(Drive.SCOPE_FILE)
                .build();

    }
}

All this I did according to instruaction (as I understood them) by Google Developers.

Now I have issues:

  • How to display LeaderBoards, when it is GameOver ?

In my Core module, I have GameOverScreen class which currently pops, when the player dies. Now I would like to post also LeaderBoards. I dont know how to do this.

  • Google API Client requires Fragment Activity when I try to build it in my ActionResolverAndroid class. But I do not have any FragmentActivity in my Project - what should I pass here?

    client = new GoogleApiClient.Builder(context)
            .enableAutoManage(/*fragmentActivity*/, /*OnConnFailedListener*/)
            .addApi(Drive.API)
            .addScope(Drive.SCOPE_FILE)
            .build();
    

I also tried to find some other tutorials on how to do this, but all are out-dated or very hard to find (especially when using LibGDX as Project Setup).

Please help me or give me advice on what to do.

David Kasabji
  • 1,049
  • 3
  • 15
  • 32
  • I'm not very familiar with the Google api but why do you need `.enableAutoManage`? You only need the `Plus.API` (to login) and `Game.API` (for the leaderboards) in the `client` for leaderboards. I transformed the standard NumberGame example into a working LibGDX game have a look, maybe it helps. https://github.com/madmenyo/NumberGame – Madmenyo Mar 09 '16 at 12:08
  • Thanks, I will check this out. – David Kasabji Mar 09 '16 at 12:15
  • Here is something that can help you with the `fragmentActivity` http://stackoverflow.com/questions/30622906/using-enableautomanage-in-fragment – Madmenyo Mar 09 '16 at 12:16

0 Answers0