Reputation: 27
Here's the code I'm using to try and set up an AlarmManager:
feedingIntent = new Intent(this, FeedingAlarmReceiver.class);
feedingPI = PendingIntent.getBroadcast(this, 0, feedingIntent, 0);
feedingAM = (AlarmManager) getSystemService(ALARM_SERVICE);
feedingAM.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 60000, feedingPI);
I basically want the feedingIntent to trigger after a minute after a button press. When I check logcat after I press the button it says my intent is null:
V/AlarmManager﹕ sending alarm PendingIntent{435f7ac8: PendingIntentRecord{435b8ed0 com.example.parentingreminders broadcastIntent}}, intent=null, type=ELAPSED_REALTIME_WAKEUP, count=1, when=959128249, repeateInterval=0
This is my first time using AlarmManager and I'm not sure what I'm doing wrong.
Thanks in advance!
Upvotes: 0
Views: 633
Reputation: 333
You need to set the corresponding action in feedingIntent to trigger the receiver
feedingIntent.setAction(Intent.ACTION_XXXX);
Upvotes: 2