ve trying to programme Android applications with java and i've got a problem that i cannot find solution.When i try to run the code,on the moment of sendind the notification,the app just explode.
Here is the code.
**AlarmManager**
private void startAlarm(Notificacion noti){
Bundle bundle =new Bundle();
bundle.putSerializable("notificacion",noti);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, 11);
AlarmManager manager=(AlarmManager)getSystemService(Context.ALARM_SERVICE);
Intent intent;
PendingIntent pendingIntent;
intent=new Intent(this,AlarmReceiver.class);
intent.putExtras(bundle);
pendingIntent=PendingIntent.getBroadcast(this,0,intent,0);
manager.setRepeating(AlarmManager.RTC_WAKEUP,SystemClock.elapsedRealtime()+3000,3000,pendingIntent);
//manager.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
// AlarmManager.INTERVAL_DAY, pendingIntent);
}
**AlarmReceiver**
public class AlarmReceiver extends BroadcastReceiver {
protected final String CHANNEL_ID ="1234";
protected final int NOTIFICACIONID =12345;
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle=intent.getExtras();
Notificacion noti=(Notificacion) bundle.getSerializable("notificacion");
String s=noti.dateTostring();
createNotificationChannel(context);
Notificacion notificacion=(Notificacion) bundle.getSerializable("notificacion");
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.drawable.plus)
.setContentTitle(s)
.setContentText("noti.getTitulo()")
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.notify(NOTIFICACIONID, builder.build());
}
```
question from:
https://stackoverflow.com/questions/65833828/how-could-i-send-information-from-an-alarmmanager-to-a-broadcastreceiverandroi 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…