geolocation - Android - Lat long values are 0.0 and 0.0 -


i trying fetch device's location application. code returns 0.0 latitude , longitude. need change? stack overflow wouldn't let me post question without sentence. hopefully, text enough.

//getting location         locationmanager lm = (locationmanager)getsystemservice(context.location_service);         locationlistener ll = new locationlistener() {              @override             public void onlocationchanged(location location) {                 // todo auto-generated method stub                 if(location !=null){                     plat = location.getlatitude();                     plong = location.getlongitude();                 }              }              @override             public void onstatuschanged(string provider, int status, bundle extras) {                 // todo auto-generated method stub              }              @override             public void onproviderenabled(string provider) {                 // todo auto-generated method stub              }              @override             public void onproviderdisabled(string provider) {                 // todo auto-generated method stub              }           };         lm.requestlocationupdates(locationmanager.gps_provider, 0, 0, ll);         log.d("lat: ",double.tostring(plat));         log.d("long: ",double.tostring(plong));  

requestlocationupdates asynchronous- takes time. value of plat , plong not ready until onlocationchanged called. can't use them until then.


Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -