android - LocationManager in Service - need to stop if no fix in 1 minute -


i have regular service start using alarms every 5 minutes. service implements locationlistener gps fix , save sqlite database.

i give service 1 minute best fix possible. if accuracy <20 before - better.

all works fine. have code checks if gps disabled exit service.

what want is: if there no fix within 1 minute - want exit service. since logic (time checks, etc) in onlocationchanged - never have chance because never location.

is there timer or can use? i'm new java, example nice. see this: on start create timer callback , in callback function cleanup , shutdown. i'm not sure if there going implications possible onlocationchanged running?

can possibly disable timer onlocationchanged?

use android.os.handler:

handler timeouthandler = new handler(); timeouthandler.postdelayed(new runnable() {     public void run() {         stopself();     } }, 60 * 1000); 

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 -