I want to fire an intent when clicking 5 times. The problem is when I click 3 times and pause for a while and again hit 2 times the intent is fired…
I want it only when clicking continuously 5 times..
static int i = 0;
public void onClick(View view) {
i++;
if (i == 5) {
i = 0;
Intent myIntent = new Intent(activity, loginActivity.class);
activity.startActivity(myIntent);
}
}
Is it possible to configure the max delay between clicks ?
You could store the timestamp of the last click and reset the click counter when the delay since last click is above a threshold: