Hi I am trying to attach an Object while set AlarmManager by using the below code,
try {
int when = (int)testDate.getTime();
Intent intent1 = new Intent(mEventService, AlarmReceiver.class);
Bundle bundle = new Bundle();
bundle.putSerializable(Contants.NOTIFICATION_DATA, (Serializable) event);
intent1.putExtras(bundle);
PendingIntent sender = PendingIntent.getBroadcast(mEventService, (int)when, intent1, PendingIntent.FLAG_UPDATE_CURRENT); //192837
// Get the AlarmManager service
AlarmManager am = (AlarmManager) mEventService.getSystemService(mEventService.ALARM_SERVICE);
am.setExact(AlarmManager.RTC_WAKEUP, when, sender);
} catch (ParseException e) {
e.printStackTrace();
}
In the Receiver class
public class AlarmReceiver extends WakefulBroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Event event = (Event) intent.getSerializableExtra(Contants.NOTIFICATION_DATA);
}
}
In the 'onReceive' the getSerializableExtra data is null. But, when I pass a String value instead of an object it is working fine. Kindly help me to find out the issue.