1
I have the following code on MyReceiver
:
@Override
public void onReceive(Context context, Intent intent){
context.startService(new Intent(context, BackgroundService.class));
}
public void setAlarm(Context context, long mills){
AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, ReceiverNotification.class);
PendingIntent pi = PendingIntent.getBroadcast(context, 2310, intent, PendingIntent.FLAG_UPDATE_CURRENT);
am.setRepeating(AlarmManager.RTC_WAKEUP, (mills + 60000), 120000, pi);
}
public void setAlarmCancel(Context context){
Intent intent = new Intent(context, MyReceiver.class);
PendingIntent sender = PendingIntent.getBroadcast(context, 2310, intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarmManager.cancel(sender);
Log.v(TAG, "Alarme cancelado!");
}
And I got this for the notifications:
public class ReceiverNotification extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent){
context.startService(new Intent(context, NotificationService.class));
}
}
When I schedule for a certain time, call the method setAlarmCancel()
, I have the return of LOG but the alarm continues. I would appreciate a help ...
From what you’re saying, it seems to be the case mark an answer as accepted. Here we do not write "solved" in the question. If you have an answer that really helped you, mark it as accepted. If you came to the solution on your own, put in the solution as an answer. So content is more organized and easier to find in the future by other people with similar problems.
– Renan Gomes
@rrnan, made ;)
– user2647038