I have this method. The problem is that it does not work when I lock the phone. Only shows me the notification if the phone has the screen on, if I block it and I put it to activate only 5 minutes later (it's 9:00 p.m. and I set it to 9:05 p.m.), nothing happens. But I leave it with the screen on if you show me the notification. Thanks in advance
public void activarBroucast(int a,int b) {
int minutos=a;
int horas=b;
Calendar c = Calendar.getInstance();
c.add(Calendar.HOUR,horas);
c.add(Calendar.MINUTE,minutos);
Timer time = new Timer();
time.schedule(new TimerTask() {
@Override
public void run() {
lanzarNotificacion();
}
},c.getTime());
}