/** * Disables alert in AlarmManger and StatusBar. * * @param id Alarm ID. */ static void disableAlert(Context context) { AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); PendingIntent sender = PendingIntent.getBroadcast( context, 0, new Intent(ALARM_ALERT_ACTION), PendingIntent.FLAG_CANCEL_CURRENT); am.cancel(sender); setStatusBarIcon(context, false); saveNextAlarm(context, ""); }
/** Disables non-repeating alarms that have passed. Called at boot. */ public static void disableExpiredAlarms(final Context context) { Cursor cur = getFilteredAlarmsCursor(context.getContentResolver()); long now = System.currentTimeMillis(); boolean status = false; if (cur.moveToFirst()) { do { Alarm alarm = new Alarm(cur); // A time of 0 means this alarm repeats. If the time is // non-zero, check if the time is before now. if (alarm.time != 0 && alarm.time < now) { enableAlarmInternal(context, alarm, false); } else { status = true; } } while (cur.moveToNext()); } cur.close(); if (status) setStatusBarIcon(context, true); }
// ���ı���״̬��statusbar�ı� public static void updateStatusBarIcon(int c1, int c2, Context context) { if (c1 < c2) setStatusBarIcon(context, true); else if (c1 > c2 && c2 == 0) setStatusBarIcon(context, false); }