I removed the code from onProviderDisabled. Had some other code there  
initially (was getting location from network - but thats very  
inaccurate)
Also tried changing the 2000 to 2 but it doesn;t make a difference. I  
still can't get a fix.

Any help please?



On 02-Jun-09, at 4:03 PM, Mark Murphy wrote:

>
> iDeveloper wrote:
>> Hi
>>
>> This is what I tried based on the suggestions in the below chain mail
>>
>> MyLocationListener myListener = new MyLocationListener();
>> LocationManager myManager =
>> (LocationManager)getSystemService(LOCATION_SERVICE);
>> myManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,  
>> 2000, 0,
>> myListener);
>>
>> This is the LocationListener class
>>
>> public class MyLocationListener implements LocationListener {
>>
>>  private static double latitude;
>>  private static double longitude;
>>
>>
>>
>>  @Override
>>  public void onLocationChanged(Location arg0) {
>>    latitude = arg0.getLatitude();
>>    longitude = arg0.getLongitude();
>>  }
>>
>>  @Override
>>  public void onProviderDisabled(String provider) {
>>
>>
>>
>>    LocationManager myManager =
>> (LocationManager)delegate.getSystemService(Context.LOCATION_SERVICE);
>>    LocationProvider name = myManager.getProvider("gps");
>>    if(name != null){
>>      Location lastGps = myManager.getLastKnownLocation("gps");
>>      if(lastGps == null){
>>        latitude = 0.0;
>>        longitude = 0.0;
>>      }
>>      else{
>>        latitude = lastGps.getLatitude();
>>        longitude = lastGps.getLongitude();
>>      }
>>    }
>>  }
>
> Why are you attempting to connect to the system service in
> onProviderDisabled()?
>
>>
>>  @Override
>>  public void onProviderEnabled(String provider) {
>>  }
>>
>>  @Override
>>  public void onStatusChanged(String provider, int status, Bundle  
>> extras) {}
>>
>>  public static double getLatitude() {
>>    return latitude;
>>  }
>>
>>  public static double getLongitude() {
>>    return longitude;
>>  }
>>
>> }
>>
>> I waited for as long as 30 seconds but none of the listener methods  
>> were
>> called. I am testing on a G1 with 1.5 SDK.
>> Can someone please tell me whats wrong with the code? Thanks
>
>
>
>
> -- 
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://twitter.com/commonsguy
>
> Need help for your Android OSS project? http://wiki.andmob.org/hado
>
> >


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