AlarmManagerIntent doesn't get called
I want to use the AlarmManager to call a BroadcastReciever:
Context ctx=getApplicationContext();
Intent StartIntent = new Intent(ctx, tartReceiver.class);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC, StartTime.toMillis(false), PendingIntent.getActivity(ctx, 6,
StartIntent, PendingIntent.FLAG_CANCEL_CURRENT ));
The receiver is declared in the manifest like this:
<receiver android:process=":remote" android:name=".StartReceiver" android:exported="true"/>
But nothing ever happens. If I use ctx.sendBroadcast(StartIntent), the intend gets called, so it should be all right, or not? I also checked the StartTime, it should be ok and I tried also 0 (which should c开发者_JAVA技巧ause the Intent to be called immediately according to the documentation).
What must I change to get it working?
JonathanK,
You want PendingIntent.getBroadcast()
not PendingIntent.getActivity()
.
精彩评论