Hey. The question is more theoretical than practical, because I can not see.
The problem is as follows. The application gives bonuses to its user once an hour, you need to put a message with a notification in the status: they say, go in and take it, if the user is not in it (he already receives it), when I receive the bonus I am writing to the memory time, I run a service with a sleep for an hour and calling Notification.Builder , a constant reminder is not required, only once.
public class MyService extends IntentService { public MyService() { super("MyService"); } @Override public void onCreate() { super.onCreate(); } @Override protected void onHandleIntent(Intent intent) { try { TimeUnit.SECONDS.sleep((System.currentTimeMillis()/1000)+(60*60)); sendNotif(); } catch (InterruptedException e) { e.printStackTrace(); } } void sendNotif() { //Notification } } Why are the messages not displayed after the release, or once / twice and all ... Maybe I didn’t understand correctly the solution?
AlarmManagerand after testing it must send a message - and here it sends it absolutely randomly. Maybe you had a solution to the problem? - Evgen Orlovsky