java - Is it possible to set an Android Notification or a later date and time that will fire when the app is not running? -


from have read seems code require app running in thread until notification fires. need notification fire @ later date , time user sees notification other notification , clicks , opens of activity, passing in data app knows do.

how can make notification fire days later without app running whole time?

do use wait accomplish this?

long millis = 60000; mynotification.wait(millis); 

here code fires immediately

notificationcompat.builder mbuilder = new notificationcompat.builder(getactivity()) .setsmallicon(r.drawable.star) .setcontenttitle("how " + me.getstring("eventtitle") + "?") .setcontenttext("click here leave review");  intent resultintent = new intent(getactivity(), setupactivity.class);  pendingintent resultpendingintent = pendingintent.getactivity( getactivity(), 0, resultintent, pendingintent.flag_update_current );      mbuilder.setcontentintent(resultpendingintent);      int mnotificationid = me.getint("eventid");     // gets instance of notificationmanager service     notificationmanager mnotifymgr =              (notificationmanager) getactivity().getsystemservice(getactivity().notification_service);       // builds notification , issues it.     mnotifymgr.notify(mnotificationid, mbuilder.build()); 

as a--c wrote, use alarmmanager schedule pendingintent invoked @ desired time. use rtc_wakeup alarm, meaning "the time based on system.currenttimemillis(), calendar uses" , "let's wake device out of sleep mode". use broadcast pendingintent, , notification code can go onreceive() method, if not need disk or network i/o information use notification itself.

note in android 4.4 rules alarmmanager changed bit. want use setexact() on android 4.4+ , set() on earlier android versions.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -