I have a countdown timer
, that starts when user Logged In
. After 10 Minutes it Logged Out
User.
It works fine, but if user stops application, then timer stops working, and user is logged in
forever.
So i put this whole thing in a service, so that it will work, either user stops application or not.
The problem is that, this has stopped working after adding Countdown Timer
in Service
. I have checked it on debug mode
, and its not going into the service
- onCreate
method.
This is how i am calling the service.
startService(new Intent(this,LogoutService.class));
My Service Class, calls the CountdownTimer Class
, first this code was written in the place where i write startService()
now
public class LogoutService extends Service {
@Override
public void onCreate() {
UserLoggedInTimer logoutTimer= new UserLoggedInTimer(60000,1000);
logoutTimer.setContext(getApplicationContext());
logoutTimer.start();
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
The countdown timer works perfectly fine when i call it without service, but here its just not getting into the service, i hope it will work fine, once my application starts the above service successfully.