Answer the question
In order to leave comments, you need to log in
How to set a time limit for sending messages in android?
Dear friend, the question is the following, there is a feedback form in the application, I would like to make a limit on the number of requests from one user by the application,
how to implement it? Similar to cookies on the web, we could insert a cookie to the user with a lifetime, and if it is alive, then do not send a request, but here is a slightly different story, what are your thoughts on this?
PS: The application does not maintain any user accounts, everything is anonymous, let's say.
Answer the question
In order to leave comments, you need to log in
Well, in general, you wrote everything correctly - you are doing something similar to cookies. Specifically - when sending, check - if there is no conditional file - send, create a file and write the time of the last send there. If there is a file - read the time of sending from there, calculate how much time has passed, if enough - send and overwrite the file. Something like this.
Cons - you can cheat by changing the time on the device or demolishing the installation of the application.
You can use the built-in database instead of the file, but somehow it's redundant, it seems to me.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question