List of usage examples for android.content Context ALARM_SERVICE
String ALARM_SERVICE
To view the source code for android.content Context ALARM_SERVICE.
Click Source Link
From source file:Main.java
private static void schedulePendingIntent(Context context, PendingIntent pendingIntent, long frequency) { AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, frequency, frequency, pendingIntent); }
From source file:Main.java
public static void cancelAlarm(Context context, int alarmId, Intent intent) { AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); PendingIntent pi = PendingIntent.getBroadcast(context, alarmId, intent, PendingIntent.FLAG_UPDATE_CURRENT); alarmManager.cancel(pi);/*w ww . j a va 2 s . co m*/ }
From source file:Main.java
public static void cancelAlarm(Context context, PendingIntent intent) { AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(intent);//ww w .j av a2 s .c om }
From source file:Main.java
public static void cancelAlarm(Context context, Intent intent, int notificationId) { AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT); alarmManager.cancel(pendingIntent);/* w w w. j av a 2s .c o m*/ }
From source file:Main.java
public static void setAlarm(Context context, PendingIntent intent, long time) { AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, time, intent); }
From source file:Main.java
private static void setIntervalDayAlarm(Context context, PendingIntent intent, long time) { AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, time, AlarmManager.INTERVAL_DAY, intent); }
From source file:Main.java
public static void stopServiceAlarm(Context context, Class<?> service) { AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(context, service); PendingIntent p = PendingIntent.getService(context, 10000, i, PendingIntent.FLAG_CANCEL_CURRENT); am.cancel(p);/*from w ww . j a v a 2s . c o m*/ }
From source file:Main.java
/** * Returns {@link AlarmManager} system service. * * @param context context//from w w w . java 2s .c om * @return alarm manager */ private static AlarmManager getAlarmManager(Context context) { return (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); }
From source file:Main.java
public static void startServiceAlarm(Context context, Class<?> service, long interval) { AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(context, service); PendingIntent p = PendingIntent.getService(context, 10000, i, PendingIntent.FLAG_CANCEL_CURRENT); am.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, 0, interval, p); }
From source file:Main.java
public static void closeService(Context context, Class<?> cls, String action) { AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, cls); intent.setAction(action);/*from w ww.ja va 2s . c om*/ PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); alarmManager.cancel(pendingIntent); }