Reputation: 1122
In my application I want the user to auto log out after 10 PM and can login after 10 AM only .Now I am picking the current time but I don't know how to this for my scenario ,If the application is not in background then also it should work(I should work in background) .
Upvotes: 0
Views: 471
Reputation: 8290
You can use AlarmManager to schedule repeating actions. Something like this:
myAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1000 * 60 * 10, pi); // Millisec * Second * Minute
Upvotes: 1
Reputation: 754
As someone mentioned in comments
Check the time when user open the app, and if he should be logged out perform the logout and perform to the LogIn activity you probably implemented.
If I misunderstood something, let me know.
If you started coding this behaviour, you can provide some code snippets
Upvotes: 0
Reputation: 1493
Download the Sample by google itself, which gives all 3 types of repeating tasks example.
https://developer.android.com/training/scheduling/alarms.html
Upvotes: 1