0

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?

Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
Aleksander Fimreite
  • 1,439
  • 2
  • 18
  • 31

1 Answers1

1

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:)

Kalpesh Lakhani
  • 1,003
  • 14
  • 28
  • I had that first, that didn't really work either. But I'll give it another try. May have been another cause earlier... I'll repost in 10min tops – Aleksander Fimreite Dec 07 '13 at 10:13
  • Doesn't seem like it does anything yet. I can see that it may be a required change still though. Any more guesses? – Aleksander Fimreite Dec 07 '13 at 10:17
  • some times you may need to restart your device to work this providers properly..see this discussion http://stackoverflow.com/q/15747543/1199602 looks like same issue as you have – Kalpesh Lakhani Dec 07 '13 at 10:17
  • Hmm, still nothing =/ – Aleksander Fimreite Dec 07 '13 at 10:33
  • if you are using `gps` then give it sometime. It may take about 20 minutes some times. For testing you can use `network` to detect location since it is fast and use log for `gps`. Also have you added necessary permissions in `androidmanifest.xml`. Also i must ask, are you referring of switching on wifi of `Settings>Wireless & Networks` or `Settings> Locations & Security>Use Wireless Networks`? Since the second option detect the location. – Rohan Kandwal Dec 10 '13 at 15:39