App should lock the screen if no activity from a user for 10 minutes

421 views
Skip to first unread message

Zagor Te Nej

unread,
Apr 22, 2021, 12:35:41 PM4/22/21
to Flutter Development (flutter-dev)
I got the requirement to "lock my mobile app if there is no activity from a user for 10 minutes". It means if the user doesn't do anything for 10 minutes after his/her last activity then I should popup a lock screen asking the user to enter a PIN in order to unlock and continue. How can I do it?
I found something similar here under "How do I create a time-based Flutter App?" but I already use GestureDetector(s) inside my app and I don't expect this proposal to work. 
Please help.

Suzuki Tomohiro

unread,
Apr 22, 2021, 12:50:11 PM4/22/21
to Zagor Te Nej, Flutter Development (flutter-dev)
Do you know how to show lock screen?
Do you know how to count 10 minutes?
Do you know how to reset the timer when a user interacts your app?

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/cc48c08c-4b6d-43a6-841f-e337664d7ee1n%40googlegroups.com.

Zagor Te Nej

unread,
Apr 22, 2021, 2:04:31 PM4/22/21
to Flutter Development (flutter-dev)
Q: Do you know how to show lock screen?
A: Yes, I already have the lock screen done.
Q: Do you know how to count 10 minutes?
A: Yes and no. The problem here is to save the date/time of the last user activity. Actually, I have to update dateTimeOfLastActivity every time when a user does something (key stroke, scrolling, navigation, etc.) and that's where the problem is.
A: Do you know how to reset the timer when a user interacts your app?
Q: As I said above, yes and no. It depends. I can do something like here
await Future.delayed(Duration(minutes: 10), () {
// popup the lock screen
});
but the problem is how to detect all the users activities.

Suzuki Tomohiro

unread,
Apr 22, 2021, 2:17:00 PM4/22/21
to Zagor Te Nej, Flutter Development (flutter-dev)
Found CountdownTimer and RestartableTimer in 
Can you try that?


> How to detect all user activity

I’m afraid that don’t know.

Reply all
Reply to author
Forward
0 new messages