I have read lot about WakefulBroadcastReceiver
... but didn't get anywhere about how to even call this from main activity. whenever I search how to call WakefulBroadcastReceiver
the result always shows me how to call IntentService
from WakefulBroadcastReceiver
...
Well to call IntentService
we write the code "startService()
" in activity or in WakefulBroadcastReceiver
...
to call BroadcastReceiver
we write
AlarmManager am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
PendingIntent.getBroadcast(this, 0, intent,PendingIntent.FLAG_UPDATE_CURRENT));
But I don't find anywhere how to call WakefulBroadcastReceiver
...
please help..
android.support.v4.content.WakefulBroadcastReceiver is a helper class that receives a device wakeful event.
you shouldoverride onReceive() method where you can call a service or perform your task.
WakefulBroadcastReceiver uses wake lock, so you must provide WAKE_LOCK permission in AndroidManifest.xml. WakefulBroadcastReceiver is implemented as
in menifest add
call AlarmReceiver like this:
also add receiver tag in manifest:
For full working sample see this link:http://www.concretepage.com/android/android-alarm-clock-tutorial-to-schedule-and-cancel-alarmmanager-pendingintent-and-wakefulbroadcastreceiver-example