Android Location Client无法解析方法
作者:互联网
我正在尝试通过onConnected方法中的位置客户端请求位置更新.我的片段实现了LocationListener,GooglePlayServicesClient.ConnectionCallbacks和GooglePlayServicesClient.OnConnectionFailedListener.
代码看起来像这样.
public class AnimatedMapFragment extends SupportMapFragment
implements LocationListener,
GooglePlayServicesClient.ConnectionCallbacks,
GooglePlayServicesClient.OnConnectionFailedListener {
private LocationRequest mLocationRequest;
private LocationClient mLocationClient;
...
mLocationRequest = LocationRequest.create();
mLocationRequest.setInterval(5000);
mLocationRequest.setFastestInterval(1000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationClient = new LocationClient(this.getActivity(), this, this);
...
@Override
public void onConnected(Bundle bundle) {
mLocationClient.requestLocationUpdates(mLocationRequest, this);
}
并且错误是“找不到适合requestLocationUpdates(LocationRequest,AnimatedMapFragment)的方法”这是非常令人困惑的,因为在位置客户端的文档中,有requestLocationUpdates的这个定义.
public void requestLocationUpdates(LocationRequest request,LocationListener listener)
有谁看到我错过了什么?
解决方法:
如果其他人遇到这个问题,那就搞清楚了.确保您正在导入:
com.google.android.gms.location.LocationClient;
我正在导入android.location.LocationClient.
标签:android,android-location 来源: https://codeday.me/bug/20190728/1564314.html