I am writing an alarm application. In my application, I put the following alarm time on the lock screen as follows:
Settings.System.putString(context.getContext().getContentResolver(), Settings.System.NEXT_ALARM_FORMATTED, systemAlarmString);
And set the system alarm icon on the right side of the notification panel as follows:
Intent alarmChanged = new Intent("android.intent.action.ALARM_CHANGED"); alarmChanged.putExtra("alarmSet", showSystemAlarmIcon); context.getContext().sendBroadcast(alarmChanged);
And put the program icon on the left side of the notification panel through the NotificationManager
When my program sets the next alarm time, everything is in order. But some time after the program is closed, the next alarm time on the lock screen and the system alarm icon on the right side of the notification panel disappear. The notification icon on the left side of the notification panel does not disappear.
I found out that not my program removes the next alarm. I try to always set a constant line on the lock screen and always show a system alarm icon. However, they disappear: an empty line is displayed on the lock screen, and the system alarm icons become hidden.
I guess another program is doing this. But I can’t find it.
My test phone is Samsung Galaxy S. Everything works fine on the emulator, but there is no third-part program there.
I found a problem.
A standard alarm sometimes clears the next alarm time. There is no alarm in the standard alarm clock, but sometimes it wakes up and does its bad things :)
The solution in my case is to catch the intent of "android.intent.action.ALARM_CHANGED" and restore the subsequent alarm data after some time.