google maps - Update location every 5sec android -
hi want user location every 5sec , user can alter duration 10sec, 15sec upto 30sec have spinner take option
this request
private static final locationrequest request = locationrequest.create() .setinterval(5000) // 5 seconds .setfastestinterval(16) // 16ms = 60fps .setpriority(locationrequest.priority_high_accuracy); this initiate start update
private void startperiodicupdates(int intervel) { stopperiodicupdates(); request.setinterval(intervel); mlocationclient.requestlocationupdates(request, this); // mconnectionstate.settext(r.string.location_requested); } i can pass user selected interval startperiodicupdates() method startperiodicupdates(5000), startperiodicupdates(15000). location update duration working fine 15sec , more 15sec if give 5sec or 10 sec location update running every second
06-18 18:46:23.638: i/location(2860): location changed location[fused 65.966697,-18.533300 acc=4 et=+1h0m13s881ms alt=15.044444] 06-18 18:46:24.642: i/location(2860): location changed location[fused 65.966697,-18.533300 acc=4 et=+1h0m14s883ms alt=15.044444] 06-18 18:46:25.642: i/location(2860): location changed location[fused 65.966697,-18.533300 acc=4 et=+1h0m15s883ms alt=15.044444] log show time interval 23, 24, 25 please give ideas.
the setinterval method not exact. this mentioned in documentation.
also, utilize same interval setfastestinterval , setinterval prevent app receiving location updates faster the interval specified in setinterval.
just add together request.setfastestinterval(intervel); startperiodicupdates method.
android google-maps android-location
No comments:
Post a Comment