【问题标题】:GoogleApiClient for multiple Api's用于多个 API 的 GoogleApiClient
【发布时间】:2016-03-04 13:06:23
【问题描述】:

我正在为我的 android 应用程序使用 GooglePlayServices。我将使用 Google+ Api 和 LocationServices Api。因此,根据 Google 的文档,我使用 addApi(Auth.GOOGLE_SIGN_IN_API)、addApi(LocationServices.API) 构建了 GoogleApiClient。每次用户启动应用程序时,我都会使用 Google+ api,但在极少数情况下我会使用 LocationServices(每 100 次启动一次)。那么最好的实现方式是什么。

通过添加两个 Api 创建单个 GoogleApiClient ?或
分别为这两个 api 创建两个 GoogleApiClient?

【问题讨论】:

  • 我也有同样的问题,你已经知道答案了吗?

标签: location-services android-googleapiclient


【解决方案1】:

如果需要,添加更多 API

mGoogleApiClient = new GoogleApiClient.Builder(this)
                .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                // Add more APIs, as needed
                .build();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-17
    • 1970-01-01
    • 2015-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多