问题描述
我刚刚更新了谷歌播放服务,以转速22和 LocationClient
类似乎缺少。这是怎么回事?
I just updated google play services to rev 22 and the LocationClient
class appears to be missing. What is going on?
推荐答案
建立在什么@CommnsWare说,这里有步骤迁移到融合的API。
Building on what @CommnsWare said, here are steps to migrate to Fused api.
第一步:获得 GoogleApiClient
的实例,而不是 LocationClient
Step 1: Get an instance of GoogleApiClient
instead of LocationClient
.
在 ConnectionCallback
(mConnectionCallbacks,mOnConnectionFailedListener下面的示例中)需要稍微修改但应该是微不足道的。
The ConnectionCallback
(mConnectionCallbacks, mOnConnectionFailedListener in example below) needs slight modification but that should be trivial.
googleApiClient = new GoogleApiClient.Builder(this)
.addApi(LocationServices.API)
.addConnectionCallbacks(mConnectionCallbacks)
.addOnConnectionFailedListener(mOnConnectionFailedListener)
.build();
第2步:更新连接和断开通话
替换 locationClient.connect()
与 googleApiClient.connect()
和 locationClient .disconnect()
与 googleApiClient.disconnect()
。
第三步:使用LocationServices.FusedLocationApi发送您的请求。 例如,
LocationServices.FusedLocationApi.getLastLocation(googleApiClient)
LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, mLocationListener);
希望这有助于!
这篇关于LocationClient类不能对谷歌游戏服务找到启22的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!