Your Location will be null most of the time, given this code. If your
first getLastKnownLocation() returns null, you can then call
requestLocationUpdates() (as you are), but then you *still* will not
have a location until your GeoUpdateHandler is called with
onLocationChanged(). Locations are not immediately available just
because your request updates -- it takes time for the location
subsystems to actually figure out where you are.

On Sat, Nov 12, 2011 at 9:45 PM, Siva Prakash <[email protected]> wrote:
> Hi
> I'm trying to take the current location using GPS or Network which ever is
> connected. The following code works fine to me if my mobile connected with
> WiFi or GPS turned ON. But if both of them turned ON/Connected then it
> doesnt give me any result
> locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000,
> 0, new GeoUpdateHandler());
> Location location = null;
> location = locationManager.getLastKnownLocation(provider);
> if (location == null)
> {
> locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
> 200, 0, new GeoUpdateHandler());
> location = locationManager.getLastKnownLocation(provider);
> }
>
> Always Im getting "location" NULL if both off them connected.
> What is wrong here ?
> Thanks
>
> --
> 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



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android 3.2 Programming Books: http://commonsware.com/books

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