1

我可以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);
    }
4

0 回答 0