problem with android GPS provider: too many updates -


although set mintime 10 seconds in requestlocatioupdate method still new location in less 1 second.

 public class gpsactivity extends activity { locationmanager mlocationmanager; textview mtextview; int count;      /** called when activity first created. */      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.main);          mtextview = (textview) findviewbyid(r.id.text);         count = 0;         mlocationmanager = (locationmanager) getsystemservice(location_service);         mlocationmanager.requestlocationupdates(locationmanager.gps_provider, 10000, 0,mgpslocationlistener);      }        handler mhandler = new handler(){           @override          public void handlemessage(message msg){              switch(msg.what){              case 1:                  mtextview.settext("new location count:"+count);              }          }     };      locationlistener mgpslocationlistener = new locationlistener(){      @override     public void onlocationchanged(location location) {         count++;         mhandler.sendemptymessage(1);      }      @override     public void onproviderdisabled(string arg0) {         // todo auto-generated method stub      }      @override     public void onproviderenabled(string arg0) {         // todo auto-generated method stub      }      @override     public void onstatuschanged(string arg0, int arg1, bundle arg2) {         // todo auto-generated method stub      }      };  } 

my program written android 2.2

any idea?

thanks in advance.

you can set distance .if not solve,youcan see :mintime minimum time interval notifications, in milliseconds. field used hint conserve power, , actual time between location updates may greater or lesser value. mindistance minimum distance interval notifications, in meters

so think time not correct,if hope update 10s,i think should use time andtimetask,or handler. or can http://androidforums.com/developer-101/107085-proper-provider-parameter-requestlocationupdates.html


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -