use of android.app.AlarmManager in project remusic by aa112901.
the class MediaService method timing.
public void timing(int time) {
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, new Intent(PAUSE_ACTION), PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC, System.currentTimeMillis() + time, pendingIntent);
}
use of android.app.AlarmManager in project Reader by TheKeeperOfPie.
the class Receiver method setAlarm.
public static void setAlarm(Context context) {
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
Intent intentInbox = new Intent(INTENT_INBOX);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intentInbox, PendingIntent.FLAG_UPDATE_CURRENT);
long interval = Long.parseLong(preferences.getString(AppSettings.PREF_INBOX_CHECK_INTERVAL, "1800000"));
if (interval > 0) {
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 1000, interval, pendingIntent);
}
Log.d(TAG, "setAlarm: " + interval);
}
use of android.app.AlarmManager in project SeriesGuide by UweTrottmann.
the class ListWidgetProvider method onUpdate.
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
// update all added list widgets
for (int appWidgetId : appWidgetIds) {
onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, null);
}
// set an alarm to update widgets every x mins if the device is awake
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
if (am != null) {
PendingIntent pi = getUpdatePendingIntent(context);
am.setRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + REPETITION_INTERVAL, REPETITION_INTERVAL, pi);
Timber.d("onUpdate: scheduled widget UPDATE alarm.");
}
}
use of android.app.AlarmManager in project SeriesGuide by UweTrottmann.
the class ListWidgetProvider method onDisabled.
@Override
public void onDisabled(Context context) {
// remove the update alarm if the last widget is gone
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
if (am != null) {
PendingIntent pi = getUpdatePendingIntent(context);
am.cancel(pi);
Timber.d("onDisabled: canceled widget UPDATE alarm.");
}
}
use of android.app.AlarmManager in project android_frameworks_base by ResurrectionRemix.
the class BluetoothDiscoverableTimeoutReceiver method setDiscoverableAlarm.
public static void setDiscoverableAlarm(Context context, long alarmTime) {
Log.d(TAG, "setDiscoverableAlarm(): alarmTime = " + alarmTime);
Intent intent = new Intent(INTENT_DISCOVERABLE_TIMEOUT);
intent.setClass(context, BluetoothDiscoverableTimeoutReceiver.class);
PendingIntent pending = PendingIntent.getBroadcast(context, 0, intent, 0);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
if (pending != null) {
// Cancel any previous alarms that do the same thing.
alarmManager.cancel(pending);
Log.d(TAG, "setDiscoverableAlarm(): cancel prev alarm");
}
pending = PendingIntent.getBroadcast(context, 0, intent, 0);
alarmManager.set(AlarmManager.RTC_WAKEUP, alarmTime, pending);
}
Aggregations