Here is my code i am storing location of user after 30min but i think when i use mobile it's service is again get restarted and again 30min starts from zero so my storing location time is not perfect 30min please tell what should i have to do ? to achieve that.
public class AppService extends Service implements LocationListener {
public void onCreate() {
super.onCreate();
System.out.println("Inside onCreate Service class");
context = this;
dbObj = new MyDB(context, "MyDB", null, 1);
dbObj.getWritableDatabase();
final Handler handler = new Handler();
timer = new Timer();
TimerTask doAsynchronousTask = new TimerTask() {
@Override
public void run() {
handler.post(new Runnable() {
public void run() {
Log.e("run", "run");
System.out.println("Inside onCreate run run");
RunServices();
// if (Utils.getNetworkStatus()) {
//
// } else {
saveDataToLocalDB();
// }
}
});
}
};
timer.schedule(doAsynchronousTask, 1800000, 1800000);
CheckLocatinData();
}
}
Aucun commentaire:
Enregistrer un commentaire