Reputation: 1449
have found no complete guide on how to implement this. I have:
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() {
@Override
public void onLocationChanged(Location location) {
//My location changed
myPosition = new LatLng(location.getLatitude(), location.getLatitude());
date = new Date();
//Update marker
myMarker.snippet(new Timestamp(date.getTime()).toString());
myMarker.position(myPosition);
//Update map
//updateMap();
//Move camera
mMap.moveCamera(CameraUpdateFactory.newLatLng(myPosition));
//mMap.animateCamera(CameraUpdateFactory.zoomTo(17));
//Show dialog
boxUpdate.show();
Log.i("Map Location", "New cache for location retrived!");
}
@Override
public void onProviderDisabled(String provider) {
//Required, but not in use
}
@Override
public void onProviderEnabled(String provider) {
//Required, but not in use
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
//Required, but not in use
}
});
So, what do I need to do to make it work? I have only WiFi enabled, but I think the cache is completly empty and wont fill up somehow. Am I missing something essential to make it listen at all?
Upvotes: 0
Views: 121
Reputation: 993
if you want to get location using your wifi then change this..
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener()
to
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, new LocationListener()
let me know if still not work.
SO force with you:)
Upvotes: 1