与 GoogleApiClient 连接,尽管它已经连接
Connect with GoogleApiClient though it has already been connected
我正在使用 GoogleAPI 的 android 应用程序中工作。在 OnCreate()
方法中,
我连接到 GoogleApiClient
。我的问题是:假设 GoogleApiClinet
是 connected
。现在,如果在另一种方法中,我再次调用与 GoogleApiClient
的连接,它是否会对我的应用程序的 speed
和 performance
造成任何问题?
同样,我也在使用 Geofencing
。假设,有些地方注册了Geofence
。我再次调用在相同地方注册的方法,它不会产生任何问题。但我的问题是,它会在内部造成任何伤害或使我的申请 slow
吗?
不,它不会对您的应用程序造成任何损害。我建议您查看此 Accessing Google APIs 文档。
这里声明,当你想连接到 Google Play 服务库中提供的 Google API 之一时(例如 Google Sign-In、游戏或驱动器),您需要创建 GoogleApiClient ("Google API Client") 的实例。 Google API 客户端为所有 Google Play 服务提供一个公共入口点,并管理用户设备与每个 Google 服务之间的网络连接。
这是使用 GoogleApiClient
和多个 API 和范围的示例代码。
GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */,
this /* OnConnectionFailedListener */)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.build();
您可以通过附加对 addApi()
and addScope()
.
的额外调用,将多个 API 和多个范围添加到同一个 GoogleApiClient
如果您想手动连接 GoogleApiClient
,那么这份 part 文档可以帮助您。
我正在使用 GoogleAPI 的 android 应用程序中工作。在 OnCreate()
方法中,
我连接到 GoogleApiClient
。我的问题是:假设 GoogleApiClinet
是 connected
。现在,如果在另一种方法中,我再次调用与 GoogleApiClient
的连接,它是否会对我的应用程序的 speed
和 performance
造成任何问题?
同样,我也在使用 Geofencing
。假设,有些地方注册了Geofence
。我再次调用在相同地方注册的方法,它不会产生任何问题。但我的问题是,它会在内部造成任何伤害或使我的申请 slow
吗?
不,它不会对您的应用程序造成任何损害。我建议您查看此 Accessing Google APIs 文档。
这里声明,当你想连接到 Google Play 服务库中提供的 Google API 之一时(例如 Google Sign-In、游戏或驱动器),您需要创建 GoogleApiClient ("Google API Client") 的实例。 Google API 客户端为所有 Google Play 服务提供一个公共入口点,并管理用户设备与每个 Google 服务之间的网络连接。
这是使用 GoogleApiClient
和多个 API 和范围的示例代码。
GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */,
this /* OnConnectionFailedListener */)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.build();
您可以通过附加对 addApi()
and addScope()
.
如果您想手动连接 GoogleApiClient
,那么这份 part 文档可以帮助您。