Android getLastKnownLocation does not report good precise result compared with Google maps app -


i in trouble using locationmanager in android. locations locationprovider's getlastknownlocation not enough in accuracy. in phone, galaxy s3, 'network' , 'passive' give me locations when use getlastknownlocation method of locationprovider. 'gps' disabled in phone. locations are..

network --> latitude : xx.5511981, longitude : xxx.1284714 passive --> latitude : xx.5511981, longitude : xxx.1284714

both give me same location information. location wrong. 50km wrong location.

in time, run google maps app in phone, reports precise location point. how can google maps app obtain higher precise location information app does?

ps. registered locationlistners every location provides '0' mintime , '0' mindistance. phone never reports location changes in several 10 minutes. think behavior acceptable because phone stayed in desk duration. condition same google maps app. reports phone's location still.

update. tested code in galaxy s2. in case, requested 3 provides' getlastknownlocation(gps, network, passive). locations null. , registered locationlisteners provides. did not report anything. in time, google map apps showed me precise location of phone. amazing!. google map apps location information from?. following test code.

      locationlistener locationlistenernetwork = new locationlistener() {         public void onlocationchanged(location location) {             log.i("location","location chagned x:"+location.getlatitude()+" y:"+location.getlongitude()+" prov:"+location.getprovider());             date d = new date(location.gettime());             log.i("location","date:"+d);         }         public void onproviderdisabled(string provider)         {             log.i("location","disable:" +provider);         }         public void onproviderenabled(string provider)         {             log.i("location","enable:" +provider);                   }         public void onstatuschanged(string provider, int status, bundle extras)          {             log.i("location","onstatuschanged:" +provider);                              }     };      locationlistener locationlistenerpassive = new locationlistener() {         public void onlocationchanged(location location) {             log.i("location","location chagned x:"+location.getlatitude()+" y:"+location.getlongitude()+" prov:"+location.getprovider());             date d = new date(location.gettime());             log.i("location","date:"+d);         }         public void onproviderdisabled(string provider)         {             log.i("location","disable:" +provider);         }         public void onproviderenabled(string provider)         {             log.i("location","enable:" +provider);                   }         public void onstatuschanged(string provider, int status, bundle extras)          {             log.i("location","onstatuschanged:" +provider);                              }     };      locationlistener locationlistenergps = new locationlistener() {         public void onlocationchanged(location location) {             log.i("location","location chagned x:"+location.getlatitude()+" y:"+location.getlongitude()+" prov:"+location.getprovider());             date d = new date(location.gettime());             log.i("location","date:"+d);         }         public void onproviderdisabled(string provider)         {             log.i("location","disable:" +provider);         }         public void onproviderenabled(string provider)         {             log.i("location","enable:" +provider);                   }         public void onstatuschanged(string provider, int status, bundle extras)          {             log.i("location","onstatuschanged:" +provider);                              }     };      void showdebug(string provider)     {         location location = lm.getlastknownlocation(provider);         if(location!=null)         {             log.i("location","all location provider:"+provider+" x:"+location.getlatitude()+" y:"+                     location.getlongitude()+" provider:"+location.getprovider()+" accuracy:"+location.getaccuracy()+" time:"+location.gettime());             date d = new date(location.gettime());             log.i("location","date:"+d);             if(this.current==null)this.current=location;             else if(this.current!=null && isbetterlocation(location,this.current))this.current=location;         }         else log.i("location","all location provider:"+provider);      }      void start()     {         lm = (locationmanager) context.getsystemservice(context.location_service);          lm.removeupdates(locationlistenernetwork);         lm.removeupdates(locationlistenerpassive);           lm.removeupdates(locationlistenergps);            lm.requestlocationupdates(locationmanager.network_provider,0, 0, locationlistenernetwork);         lm.requestlocationupdates(locationmanager.passive_provider, 0, 0, locationlistenerpassive);         lm.requestlocationupdates(locationmanager.gps_provider, 0, 0, locationlistenergps);          showdebug(locationmanager.network_provider);         showdebug(locationmanager.passive_provider);         showdebug(locationmanager.gps_provider);     }  


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -