我已添加:
implements GoogleApiClient.ConnectionCallbacks, LocationListener, GpsStatus.Listener
和
mGoogleApiClient = new GoogleApiClient.Builder(context)
.addApi(LocationServices.API)
.addApi(Wearable.API)
.addConnectionCallbacks(this)
.build();
mGoogleApiClient.connect();
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
locationManager.addGpsStatusListener(this);
和
@Override
public void onGpsStatusChanged(int event) {
Log.d(TAG, "GPS status change: " + event);
switch(event) {
case GpsStatus.GPS_EVENT_FIRST_FIX:
break;
case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
break;
}
}
但是没有为Fused Location API调用onGpsStatusChanged。这可能吗?
答案 0 :(得分:0)
这对我来说很好。我能够在onGpsStatusChanged()方法中接收事件。如果你想查看我的代码。
我正在使用以下版本
的游戏服务的gradle依赖性compile 'com.google.android.gms:play-services-location:8.4.0'
用工具
class FusedLocationProviderService extends Service implements
GpsStatus.Listener,
LocationListener,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
ResultCallback<LocationSettingsResult> {
public void initialize() {
googleApiClient = new GoogleApiClient.Builder(context)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API).build();
locationManager = (LocationManager) context
.getSystemService(LOCATION_SERVICE);
locationManager.addGpsStatusListener(this);
}
}