Я думаю, что самый простой и прямой способ сделать это - сохранить дату истечения срока действия в SharedPreferences:
// use this code on onRewarded function to store the datetime when user completed his AD.
SharedPreferences sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putLong("ExpiredDate", new Date().getTime());
editor.apply();
, а затем проверить, что если дата истечения срока действия равна 24 часам, продолжайте, пока не появится уведомление об ошибке.
// use this code to check before showing AD
SharedPreferences sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
long startDateValue = sharedpreferences.getLong("ExpiredDate");
long endDateValue = new Date().getTime();
long diff = startDateValue - endDateValue;
long seconds = diff / 1000;
long minutes = seconds / 60;
long hours = minutes / 60;
long days = hours / 24;
if(hours < 24){
//show error that you have completed only "+ hours +" till now, wait more to see next ad.
} else {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.remove("ExpiredDate");
editor.apply();
// show ads now...
}
Я не проверял этот код, но он должен работать ..