Issue
I'm working on an app in which I want to add a functionality that shows an alert dialog box only once a day when the user opens the app. I'm done with the dialog box I used the boolean variable
if this bool value is true
then show dialog else don't show the dialog. Once the dialog opens on tap of the button I set the bool value to false
. But my question is how it will set true
again at the end of the day?
What should I need to do so the bool value again set to true at the end of the day?
Solution
Instead of using a boolean, you need the last date/time the dialog was shown.
Every time a situation occurs in which you may need to show the dialog, you get the current date/time now and compare that with date/time of the last dialog showing.
Because you can't be sure if the app will be killed or now, you also need to store the last date/time the app was shown on disk.
Answered By - meaning-matters
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.