I have used manager.requestLocationUpdates(\"gps\", 1000, 0, new LocationDetector());
to get update after every second. But this method is never triggering
This is a duplicate of this question, also asked by you. In any case, you could try using GoogleAPIClient
- like this:
LocationRequest locationRequest = LocationRequest.create();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setInterval(60000); // update every (1) minutes
LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient,locationRequest, yourLocationDetector );
Where the googleApiClient is instantiated and connected in some helper method like this:
/**
* Helper method to connect the Google API Client
*/
private void connectGoogleAPIClient() {
googleApiClient = new GoogleApiClient.Builder(context)
.addApi(LocationServices.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
googleApiClient.connect();
}
You also need to make sure you have added the permission:
Your problem might be related to the one discussed here - so please also look at the selected answer there and see if it does not help your case as well.