App crash when AlarmManager registration
When registering alarms in AlarmManager, some Samsung Smart phones have 500 limited limits on the number of alarms.
There is a crash issue because getting 'Too many alarms (500) registered' Exception.
Exception blocking the crash by checking the Exception when AlarmManager registration.
AlarmManager registration example
void registerAlarmManger(final long interval) {
Log.d(TAG, "Alaram register");
customlarmManager.cancel(alarmIntent);
try {
customAlarmManager.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 100 * I,
PendingIntent.getBroadcast(this.context, 0, new Intent(this.context, CustomAlarmReceiver.class), PendingIntent.FLAG_CANCEL_CURRENT));
} catch (Exception e) {
Log.w(TAG, "Too many alarms!");
}
} |