Hi,

I have been struggling to get onLocationChanged called, but I'm not
sure it does not.
Here're my code

                criteria = new Criteria();
                criteria.setAccuracy(Criteria.ACCURACY_FINE);
                criteria.setPowerRequirement(Criteria.POWER_LOW);
                criteria.setAltitudeRequired(false);
                criteria.setBearingRequired(false);
                criteria.setSpeedRequired(false);
                criteria.setCostAllowed(true);

                String locationContext = Context.LOCATION_SERVICE;
                locationManager = (LocationManager)context.getSystemService
(locationContext);

                String provider = locationManager.getBestProvider(criteria, 
true);

                Location location = 
locationManager.getLastKnownLocation(provider);
                locationManager.requestLocationUpdates(provider,0 ,
100.0f,locationListener);

and ..... in the methods below, only onStatusChanged is being called,
and not onLocationChanged

     private final LocationListener locationListener = new
LocationListener(){
        public void onLocationChanged(Location location)
        {
                Log.d("onLocationChanged","update now");
        }

        public void onProviderDisabled(String provider)
        {
                Log.d("onProviderDisabled",provider.toString());
        }

        public void onProviderEnabled(String provider){
                Log.d("onProviderEnabled",provider.toString());
        }
        public void onStatusChanged(String provider, int status, Bundle
extras){
                Log.d("Provider status changed", provider.toString());
        }
    };

here are permissions from my manifest

    <uses-permission
android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission
android:name="android.permission.ACCESS_MOCK_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_GPS" />
    <uses-permission
android:name="android.permission.READ_PHONE_STATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.CAMERA" />


and I missing something ?
I have tried to add this line below requestLocationUpdate

Location location = locationManager.getLastKnownLocation(provider);
because I thought this might get me the last location just requested
from the requestLocationUpdate in the line before it, but it does not
help to retrieve the current location. It still retrieves the previous
location
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to