I want to disable tasks for 1 hour with countdowntimer. but when app is close, countdowntimer is stop working
I have tried Intent service but seems like its not working
final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
Context mContext;
public IBinder onBind(Intent intent) {
return null;
}
public void onCreate() {
super.onCreate();
mContext = this;
startService();
}
private void startService() {
scheduler.scheduleAtFixedRate(runner, 0, 30, TimeUnit.SECONDS);
}
final Runnable runner = new Runnable() {
public void run() {
mHandler.sendEmptyMessage(1212);
Toast.makeText(mContext, "TImer is out", Toast.LENGTH_SHORT).show();
}
};
public void onDestroy() {
super.onDestroy();
Toast.makeText(this, "Service Stopped ...", Toast.LENGTH_SHORT).show();
}
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
//do what ever you want as 3hrs is completed
}
};