manabreak manabreak - 1 year ago 70
Android Question

AlarmManager doesn't trigger a WakefulBroadcastReceiver

I'm trying to launch an intent service using an AlarmManager and a WakefulBroadcastReceiver. I can launch the service using

and it works as it should, but I can't get it to launch with AlarmManager.

The code for launching it is like this:

protected void onPause()

AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
Intent i = new Intent(this, Notifier.class);
PendingIntent pi = PendingIntent.getService(this, 0, i, 0);

am.set(RTC_WAKEUP, System.currentTimeMillis(), pi);

class is like this:

public class Notifier extends WakefulBroadcastReceiver
public void onReceive(Context context, Intent intent)
Log.i("Notifier", "onReceive()");
ComponentName comp = new ComponentName(context.getPackageName(), NotifierService.class.getName());
startWakefulService(context, (intent.setComponent(comp)));

And the
is like this:

public class NotifierService extends IntentService
private static final String TAG = "NotifService";

public NotifierService()

protected void onHandleIntent(Intent intent)
Log.i(TAG, "NotifierService: handling an intent");

The manifest has these:

<service android:name=".NotifierService" />
<receiver android:name=".Notifier" />

Why doesn't the AlarmManager trigger the receiver?

Answer Source


Intent i = new Intent(this, Notifier.class);


Intent i = new Intent(this, NotifierService .class);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download