When the button is clicked, the current time is saved.
The checkAndShowAd method displays an ad if 5 minutes have passed since the last click. If not, no ad will be displayed. In short, when the user clicks on the "win reward" button, he will not watch ads for 5 minutes. So the reward he will win is; You will watch fewer ads.
Can I do this? Does it cause any problems? Because I don't give any in-app rewards in return, I just make them watch fewer ads.
long lastClickTime = 0;
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
1718226084296
lastClickTime = System.currentTimeMillis();
}
});
private void checkAndShowAd() {
long currentTimeMillis = System.currentTimeMillis();
// 5 minutes = 5 * 60 * 1000
if (currentTimeMillis - lastClickTime > 5 * 60 * 1000) {
showAd();
}
}
