1

Can I use in onConnected from multiple onLocationChanged? for example first onLocationChangedfor update location user and second onLocationChanged for other works :

 @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);
    }
  • Why you need to different onConnected ? – M D Sep 27 '16 at 06:14
  • @M D .In first onLocationChanged I need to track user each seconds and in second onLocationChanged I need to use from isLocationOnPath() every 100 meters. –  Sep 27 '16 at 06:18
  • @M D .Can I use from this way ? –  Sep 27 '16 at 06:47
  • Yes but it's useless becoz it's easy to handle and maintain single Object of googleApiClient – M D Sep 27 '16 at 06:48
  • @M D .Can you recommend a better solution ? –  Sep 27 '16 at 06:53
  • 1
    Get first location and save it some where and when you get next location get distance from save location to new location. If dis < 100 then use it. – M D Sep 27 '16 at 07:06
  • @M D .Thanks a lot for your help but,is this way slow ? –  Sep 27 '16 at 07:17

0 Answers0