How to wake up the android app at specific time? -


i want wake whole android app daily @ 9 . tried using alarm manager of android. calls pending intent. in case not pending intent , want wake full app. following code . beginner in android development appreciated .

public void setalarm() {     calendar cal = calendar.getinstance();     cal.set(calendar.hour_of_day, 09);     cal.set(calendar.minute, 00);     cal.set(calendar.second, 0);     cal.set(calendar.millisecond, 0);     alarmmanager alarmmgr = (alarmmanager)getsystemservice(context.alarm_service);     intent intent = new intent(this, mainactivity.class);     pendingintent pendingintent = pendingintent.getbroadcast(this, 0, intent, 0);     alarmmgr.set(alarmmanager.rtc_wakeup, cal.gettimeinmillis(), pendingintent);   }  

and in mainactivity class :

public class mainactivity extends activity {    string ua = "mozilla/5.0 (android; tablet; rv:20.0) gecko/20.0 firefox/20.0";   @override   protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     webview mywebview = (webview) findviewbyid(r.id.webview);     mywebview.setbackgroundcolor(0);     websettings websettings = mywebview.getsettings();     mywebview.getsettings().setuseragentstring(ua);     websettings.setjavascriptenabled(true);     mywebview.setwebchromeclient(new webchromeclient());     websettings.setdomstorageenabled(true);     mywebview.setwebviewclient(new myappwebviewclient());     mywebview.loadurl("file:///android_asset/www/index.html");     setalarm();   } } 

but @ 9 not waking app . mistakes ??

if opening activity should using pendingintent.getactivity rather pendingintent.getbroadcast


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -