我可以onConnected
从多个中使用onLocationChanged
吗?例如,第一个onLocationChanged
用于更新位置用户,第二个onLocationChanged
用于其他作品:
@Override
public void onConnected(@Nullable Bundle bundle) {
LocationListener mListenerone = new LocationListener() {
@Override
public void onLocationChanged(final Location location) {
}
};
LocationRequest requestone = LocationRequest.create();
requestone.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
requestone.setInterval(100);
requestone.setFastestInterval(100);
LocationServices.FusedLocationApi.requestLocationUpdates(mLocationClient, requestone, mListenerone);
LocationListener mListenertwo = new LocationListener() {
@Override
public void onLocationChanged(final Location location) {
}
};
LocationRequest requesttwo = LocationRequest.create();
requesttwo.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
requesttwo.setInterval(10000);
requesttwo.setFastestInterval(1000);
LocationServices.FusedLocationApi.requestLocationUpdates(mLocationClient, requesttwo, mListenertwo);
}