passing the GoogleApiClient obj from one activity to another

前端 未结 4 1197
旧巷少年郎
旧巷少年郎 2021-02-19 04:54

I want to be able to update my score for my leaderboard in a different activity other than the one that creates the GoogleApiClient obj ( the main activity ).

What is th

4条回答
  •  [愿得一人]
    2021-02-19 05:25

    Ok I thought i would answer my own Question as i have found a method that currently suits me. Alot of this has come from another answered question found here!

    This method uses the basegameutil so going from Lee's answer from the link i can just have both my activities extend the BaseGameActivity and add the required methods.

    I then create a new instance of the GoogleApiClient in my second activity and then get the api client like this:

    mGoogleApiClient = getApiClient();
    

    i can now pass this around my second activity and call the methods as i wish.

    As Lee States in his answer, you can have multiple instances of the google api client and still wont be asked to sign in for each of them as it knows you are already signed in.

提交回复
热议问题