Monday, 12 August 2013

Spam protection onclick()

Spam protection onclick()

I'm trying to build a SMS application that sends a SMS with one press on a
button, this part is working but now I'm trying to implement a spam
protection. The spam protection means that you only can send 1 SMS per 10
seconds (or higher).
I've tried this:
sentSMS.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Timer timer = new Timer();
int seconds = 10000;
timer.schedule(new TimerTask() {
public void run() {
processClick();
}
}, seconds);
}});
But this is not working when I press the button twice the SMS is also
sending twice.
Maybe it's also a idea to make a toast which contains how many seconds the
user have to wait, something like this:
Toast.makeText(getBaseContext(), "Spam protection, wait "+secondstowait,
Toast.LENGTH_SHORT).show();
Is this all possible to make?

No comments:

Post a Comment