use of android.app.AlarmManager in project HomeMirror by HannahMitt.
the class AlarmReceiver method startMirrorUpdates.
public static void startMirrorUpdates(Context context) {
AlarmManager alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, AlarmReceiver.class);
PendingIntent alarmIntent = PendingIntent.getBroadcast(context, REQUEST_CODE, intent, 0);
alarmMgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + MINUTES_10, MINUTES_10, alarmIntent);
}
use of android.app.AlarmManager in project Gadgetbridge by Freeyourgadget.
the class SleepAlarmWidget method setAlarmViaAlarmManager.
/**
* Use the Android alarm manager to create the alarm icon in the status bar.
*
* @param packageContext {@code Context}: A Context of the application package implementing this
* class.
* @param triggerTime {@code long}: time at which the underlying alarm is triggered in wall time
* milliseconds since the epoch
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setAlarmViaAlarmManager(Context packageContext, long triggerTime) {
AlarmManager am = (AlarmManager) packageContext.getSystemService(Context.ALARM_SERVICE);
// TODO: launch the alarm configuration activity when clicking the alarm in the status bar
Intent intent = new Intent(packageContext, ConfigureAlarms.class);
PendingIntent pi = PendingIntent.getBroadcast(packageContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
am.setAlarmClock(new AlarmManager.AlarmClockInfo(triggerTime, pi), pi);
}
use of android.app.AlarmManager in project AndroidChromium by JackyAndroid.
the class UrlManager method cancelClearNotificationAlarm.
private void cancelClearNotificationAlarm() {
PendingIntent pendingIntent = createClearNotificationAlarmIntent();
AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
alarmManager.cancel(pendingIntent);
}
use of android.app.AlarmManager in project android_frameworks_base by DirtyUnicorns.
the class DaylightHeaderProvider method startAlarm.
private void startAlarm() {
// TODO actually this should find out the next needed alarm
// instead of forcing it every interval
final Calendar c = Calendar.getInstance();
final AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
if (mAlarmIntent != null) {
alarmManager.cancel(mAlarmIntent);
}
Intent intent = new Intent(StatusBarHeaderMachine.STATUS_BAR_HEADER_UPDATE_ACTION);
mAlarmIntent = PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
// make sure hourly alarm is aligned with hour
if (mAlarmIntervalMinutes == 0) {
c.add(Calendar.HOUR_OF_DAY, 1);
c.set(Calendar.MINUTE, 0);
}
long alarmStart = c.getTimeInMillis();
long interval = mAlarmIntervalMinutes == 0 ? AlarmManager.INTERVAL_HOUR : mAlarmIntervalMinutes * 60 * 1000;
alarmManager.setInexactRepeating(AlarmManager.RTC, alarmStart, interval, mAlarmIntent);
}
use of android.app.AlarmManager in project AdMoney by ErnestoGonAr.
the class AgregarNotf method agregarNotf.
public void agregarNotf(Context aContext, String nombre, float cantidad, String fecha, int frecuencia, int id) {
java.util.Calendar calendar = java.util.Calendar.getInstance();
String[] f = fecha.split("-");
calendar.set(Calendar.MONTH, (Integer.parseInt(f[1]) - 1));
calendar.set(Calendar.DAY_OF_MONTH, Integer.parseInt(f[2]));
calendar.set(Calendar.YEAR, Integer.parseInt(f[0]));
calendar.set(Calendar.HOUR_OF_DAY, 18);
calendar.set(Calendar.MINUTE, 2);
calendar.set(Calendar.SECOND, 0);
java.util.Calendar temp = java.util.Calendar.getInstance();
if (calendar.before(temp)) {
calendar = java.util.Calendar.getInstance();
calendar.add(Calendar.MINUTE, 1);
}
Intent intent1 = new Intent(aContext, AlarmReceiver.class);
intent1.putExtra("NotfNombre", nombre);
intent1.putExtra("NotfCantidad", cantidad);
intent1.putExtra("NotfFecha", fecha);
intent1.putExtra("NotfFrecuencia", frecuencia);
intent1.putExtra("NotfId", id);
PendingIntent pendingIntent = PendingIntent.getBroadcast(aContext, 0, intent1, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) aContext.getSystemService(aContext.ALARM_SERVICE);
am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
}
Aggregations