Please post the code in your Activity in which you register this
listener with the system. The above code appears to be correct.

-Nick




On Apr 27, 6:32 am, mudit <[email protected]> wrote:
> Hi all
>
> I am trying develop an application which shows user current location.
> To find user's current location i am using following code:
>
> import android.location.Location;
> import android.location.LocationListener;
> import android.location.LocationProvider;
> import android.os.Bundle;
>
> public class MyLocationListener implements LocationListener {
>
> private static double latitude;
> private static double longitude;
>
> public static boolean gpsAvailable = false;
>
> @Override
> public void onLocationChanged(Location arg0) {
>     latitude = arg0.getLatitude();
>     longitude = arg0.getLongitude();
>     // Log.d("MyLocationListener", "onLocationChanged");
>
> }
>
> @Override
> public void onProviderDisabled(String provider) {
>
>     // Log.d("MyLocationListener", "onProviderDisabled");
>
> }
>
> @Override
> public void onProviderEnabled(String provider) {
>     // Log.d("MyLocationListener", "onProviderEnabled");
>
> }
>
> @Override
> public void onStatusChanged(String provider, int status, Bundle
> extras) {
>     // Log.d("MyLocationListener", "onStatusChanged called");
>     if (provider.equals("gps") && status !=
> LocationProvider.AVAILABLE) {
>         gpsAvailable = false;
>         // Log.d("MyLocationListener", "status NOTAVAILABLE");
>     } else {
>         gpsAvailable = true;
>         // Log.d("MyLocationListener", "status AVAILABLE");
>     }
>
> }
>
> public static double getLatitude() {
>     return latitude;
>
> }
>
> public static double getLongitude() {
>     return longitude;
>
> }
> }
>
> I have used this code to successfully get the GPS location on android
> 1.5 SDK but with 2.0 i am unable to find user's current location. I
> have tested this code on Droid and Magic.
>
> Please help..
>
> --
> 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 
> athttp://groups.google.com/group/android-developers?hl=en

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