android - Receiver, service, alarmmanager and status bar notification -


i have receiver , service run on device start up, let`s user never turn off device, how should handle this?

how schedule status bar notification alarmmanager receiver/service?

package it.bloomp.service;  import android.app.service; import android.content.intent; import android.os.ibinder;  public class eventsnotificationservice extends service {      @override     public ibinder onbind(intent intent) {         return null;     }      @override     public void oncreate() {         super.oncreate();         system.out.println("service created.");     }      @override     public void ondestroy() {         super.ondestroy();         system.out.println("service destroyed.");     }      @override     public void onstart(intent intent, int startid) {         super.oncreate();         system.out.println("service started.");     } } 

...

package it.bloomp.service;  import android.content.broadcastreceiver; import android.content.context; import android.content.intent;  public class eventsnotificationreceiver extends broadcastreceiver {      @override     public void onreceive(context context, intent intent) {         if ("android.intent.action.boot_completed".equals(intent.getaction())) {             intent serviceintent = new intent(context, eventsnotificationservice.class);             context.startservice(serviceintent);         }     } } 

you can use other kind of broadcast receiver suitable requirements. or can set time period run task periodically using timer class, ;

timer time; time..scheduleatfixedrate(new timertask() {                     @override         public void run() {            //your task                  }     }, 0/*start delay*/, 1000/*delay period*/); 

update : schedule notification can somethng this:

intent intentsafety_check_service = new intent(activity_add_safety_check.this, safety_check_service.class);      pendingintent = pendingintent.getservice(activity_add_safety_check.this,                integer.parseint(currcheckid), intentsafety_check_service, 0);      alarmmanager alarmmanager = (alarmmanager)getsystemservice(alarm_service);      calendar calendar = calendar.getinstance();      calendar.settimeinmillis(/*your alarm date converted in milliseconds*/);      alarmmanager.set(alarmmanager.rtc_wakeup, calendar.gettimeinmillis(), pendingintent); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -