0
I call the service at onPause()
And once I leave the app, it stops responding after a while. From what I’ve researched, it may be that the processes are too heavy to execute in the background. I need to check the schedule to see if it’s time to send the notification.
public int onStartCommand(Intent intent, int flags, int startId) {
if (inicio != null) {
ok = trataData(d2,d3);
horaNotificacao.set(Calendar.MILLISECOND,this.intervalo);
while (ok == true){
try {
agora = new Date();
if(agora.equals(horaNotificacao.getTime())){
gerarNotificacao();
horaNotificacao.set(Calendar.MILLISECOND,this.intervalo);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
ok = trataData(d2,d3);
}
}
return START_STICKY;
}
treatise:
public boolean trataData(Date d2, Date d3) {
boolean ok = false;
Date d1 = new Date();
if (d1.before(d2) && d1.after(d3)){
ok = true;
}
return ok;
}
I think the problem is in this ok loop, but I see another way to do the check
It was right! Thanks again :D
– Éowyn