i build app which give Location update to server in background using service and broadcastreceiver.i put timer(Run every X Minute) which run method of location.it include fatch lattitude,longitude and update to server with API Call. I have a problem and quastions . there is a list of this.
1.my timer goes sleep when device is in standby mode or sleep mode
2.i have to update location if user last location and current location distance 500m or greater.
3.I want to know how much minute or second tack device for going sleep mode?
4.my timer run perfactly in running devoce mode than why stop or sleep in device sleep mode?
my timertask
class TimeDisplayTimerTask extends TimerTask {
@Override
public void run() {
// run on another thread
mHandler.post(new Runnable() {
@Override
public void run() {
location();
notifyUser2();
Log.d("timeeeeeeee22222222", "time22222222");
// display toast
}
});
}
//in oncreate
if (mTimer != null) {
mTimer.cancel();
} else {
// recreate new
mTimer = new Timer();
}
// schedule task
mTimer.scheduleAtFixedRate(new TimeDisplayTimerTask(), 0, NOTIFY_INTERVAL);
Is the currect Way to timer run? if yes than Why it Sleep while device in standby mode or sleep mode?
Help me i searched lots of sites but can't get it. Thanks in advance