I already have an alarm that fires daily which has FLAG_UPDATE_CURRENT
. This is the log from developer's console.
java.lang.SecurityException: !@Too many alarms (500) registered from pid 32326 uid 10206
at android.os.Parcel.readException(Parcel.java:1540)
at android.os.Parcel.readException(Parcel.java:1493)
at android.app.IAlarmManager$Stub$Proxy.set(IAlarmManager.java:206)
at android.app.AlarmManager.setImpl(AlarmManager.java:428)
at android.app.AlarmManager.set(AlarmManager.java:215)
at com.google.firebase.iid.FirebaseInstanceIdService.zzagl(Unknown Source)
at com.google.firebase.iid.FirebaseInstanceIdService.zzd(Unknown Source)
at com.google.firebase.iid.FirebaseInstanceIdService.zza(Unknown Source)
at com.google.firebase.iid.FirebaseInstanceIdService.zzm(Unknown Source)
at com.google.firebase.iid.zzb$2.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
I am using Firebase 9.6.1.
UPDATE:
public static void setAlarm(Context context, boolean isSet) {
try {
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, AlarmReceiver.class);
boolean isWorking = (PendingIntent.getBroadcast(context,
SettingsActivity.REQUEST_CODE, intent, PendingIntent.FLAG_NO_CREATE) != null);
if (isSet && !isWorking) {
PendingIntent sender = PendingIntent.getBroadcast(context,
SettingsActivity.REQUEST_CODE, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR, 10);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
am.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
AlarmManager.INTERVAL_DAY, sender);
} else {
PendingIntent pendingIntent = PendingIntent.getBroadcast(context,
SettingsActivity.REQUEST_CODE, intent,
PendingIntent.FLAG_CANCEL_CURRENT);
am.cancel(pendingIntent);
pendingIntent.cancel();
}
} catch (Exception e) {
Crashlytics.logException(e);
}
}
According to this thread, the bug has been fixed by the Firebase team in the 10.0 release. Release notes are here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With