android - I am not getting gps coordinates from NETWORK_PROVIDER sometimes -
locationmanager mlocmanager = (locationmanager)getsystemservice(context.location_service);
locationlistener mloclistener = new mylocationlistener(); mlocmanager.requestlocationupdates( locationmanager.network_provider, 0, 0, mloclistener); //init(); } /* class location listener */ public class mylocationlistener implements locationlistener { @override public void onlocationchanged(location loc) { //_pd.dismiss(); loc.getlatitude(); loc.getlongitude(); string text = "my current location is: " +"latitud = " + loc.getlatitude() +"longitud =" + loc.getlongitude(); txtinfo.settext(text); toast.maketext( getapplicationcontext(),text,toast.length_short).show(); } @override public void onproviderdisabled(string provider) { toast.maketext( getapplicationcontext(),"gps disabled",toast.length_short ).show(); } @override public void onproviderenabled(string provider) { toast.maketext( getapplicationcontext(),"gps enabled",toast.length_short).show(); } @override public void onstatuschanged(string provider, int status, bundle extras) { } } this code....sometimes gps coordinates , dont why happening?
getting geo fix using gps requires long time, hence need switch between wirless network provider , gps geo coordinates reliably. idea first poll wireless network , if not enabled/available fallback gps provider.
good reference : android-location-providers-gps-network-passive
Comments
Post a Comment