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
Post a Comment