Android Location issues -
i'm trying understand android location found lot of code on web, different , juggle libraries in different ways confuses me. wasn't able find commonly used approach.
basically need location using gps, if location not retrieved within 90 seconds using gps, location provided network. simplest way that?
i tested following snippet results on device not robust not clear how make sure, getlastknownlocation() not getting old stored location not current. thanks!
location = locationmanager.getlastknownlocation(locationmanager.network_provider); if (location != null) { gps_latitude = location.getlatitude(); gps_longitude = location.getlongitude(); gps_timestamp = location.gettime(); gps_accuracy = location.getaccuracy(); gps_provider = location.getprovider(); gps_speed = location.getspeed(); }
try locationclient best last known location available. class uses mix of gps, wifi , sensors detect current location automatically. there no need decide between gps or network anymore.
here's guide how use it.
edit: have use google play services library, compatible api 8.
Comments
Post a Comment