Search in sources :

Example 46 with AlarmManager

use of android.app.AlarmManager in project cw-advandroid by commonsguy.

the class OnBootReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    Intent i = new Intent(context, OnAlarmReceiver.class);
    PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
    mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 60000, PERIOD, pi);
}
Also used : AlarmManager(android.app.AlarmManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 47 with AlarmManager

use of android.app.AlarmManager in project AisenWeiBo by wangdan.

the class UnreadService method clearAlarm.

private static void clearAlarm() {
    Logger.v(TAG, "clear unread block");
    AlarmManager am = (AlarmManager) GlobalContext.getInstance().getSystemService(ALARM_SERVICE);
    am.cancel(getOperation());
}
Also used : AlarmManager(android.app.AlarmManager)

Example 48 with AlarmManager

use of android.app.AlarmManager in project AisenWeiBo by wangdan.

the class UnreadService method resetTheTime.

private void resetTheTime() {
    Logger.v(TAG, "reset unread block");
    AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
    // 指定时间
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());
    calendar.add(Calendar.SECOND, AppSettings.getUnreadInterval());
    Logger.v(TAG, String.format("未读消息,在%s后还是读取", AppSettings.getUnreadInterval()));
    am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), getOperation());
}
Also used : Calendar(java.util.Calendar) AlarmManager(android.app.AlarmManager)

Example 49 with AlarmManager

use of android.app.AlarmManager in project Conversations by siacs.

the class XmppConnectionService method scheduleNextIdlePing.

@TargetApi(Build.VERSION_CODES.M)
private void scheduleNextIdlePing() {
    Log.d(Config.LOGTAG, "schedule next idle ping");
    AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    Intent intent = new Intent(this, EventReceiver.class);
    intent.setAction(ACTION_IDLE_PING);
    alarmManager.setAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + (Config.IDLE_PING_INTERVAL * 1000), PendingIntent.getBroadcast(this, 0, intent, 0));
}
Also used : AlarmManager(android.app.AlarmManager) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) TargetApi(android.annotation.TargetApi)

Example 50 with AlarmManager

use of android.app.AlarmManager in project muzei by romannurik.

the class MuzeiArtSource method setUpdateAlarm.

private void setUpdateAlarm(long nextTimeMillis) {
    if (!isEnabled()) {
        Log.w(TAG, "Source has no subscribers, not actually scheduling next update" + ", id=" + mName);
        return;
    }
    if (nextTimeMillis < System.currentTimeMillis()) {
        Log.w(TAG, "Refusing to schedule next artwork in the past, id=" + mName);
        return;
    }
    AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
    am.set(AlarmManager.RTC, nextTimeMillis, getHandleNextCommandPendingIntent(this));
    Log.i(TAG, "Scheduling next artwork (source " + mName + ") at " + new Date(nextTimeMillis));
}
Also used : AlarmManager(android.app.AlarmManager) Date(java.util.Date)

Aggregations

AlarmManager (android.app.AlarmManager)471 PendingIntent (android.app.PendingIntent)349 Intent (android.content.Intent)323 Calendar (java.util.Calendar)75 SuppressLint (android.annotation.SuppressLint)24 Date (java.util.Date)24 Context (android.content.Context)22 SharedPreferences (android.content.SharedPreferences)20 SimpleDateFormat (java.text.SimpleDateFormat)18 Test (org.junit.Test)17 VisibleForTesting (com.android.internal.annotations.VisibleForTesting)13 Config (org.robolectric.annotation.Config)13 Handler (android.os.Handler)11 HashMap (java.util.HashMap)11 PowerManager (android.os.PowerManager)10 File (java.io.File)10 Map (java.util.Map)10 Activity (android.app.Activity)9 ShadowAlarmManager (org.robolectric.shadows.ShadowAlarmManager)9 TargetApi (android.annotation.TargetApi)8