passing the GoogleApiClient obj from one activity to another

前端 未结 4 1193
旧巷少年郎
旧巷少年郎 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:26

    If you need to be constantly connected to the GoogleApiClient then I would probably make a singleton class to handle GoogleApiClient calls (http://en.wikipedia.org/wiki/Singleton_pattern) or make a background service that would run for the whole app lifecycle (https://developer.android.com/training/best-background.html).

    From the developer documentation:

    GoogleApiClient is used with a variety of static methods. Some of these methods require that GoogleApiClient be connected, some will queue up calls before GoogleApiClient is connected; check the specific API documentation to determine whether you need to be connected.

    If you don't need to send the data immediately GoogleApiClient is going to queue the data to be sent for you and just send it in the primary Activity.

提交回复
热议问题