Search in sources :

Example 86 with AlarmManager

use of android.app.AlarmManager in project android_packages_apps_Settings by LineageOS.

the class ZonePicker method onListItemClick.

@Override
public void onListItemClick(ListView listView, View v, int position, long id) {
    // Ignore extra clicks
    if (!isResumed())
        return;
    final Map<?, ?> map = (Map<?, ?>) listView.getItemAtPosition(position);
    final String tzId = (String) map.get(ZoneGetter.KEY_ID);
    // Update the system timezone value
    final Activity activity = getActivity();
    final AlarmManager alarm = (AlarmManager) activity.getSystemService(Context.ALARM_SERVICE);
    alarm.setTimeZone(tzId);
    getActivity().onBackPressed();
}
Also used : Activity(android.app.Activity) AlarmManager(android.app.AlarmManager) HashMap(java.util.HashMap) Map(java.util.Map)

Example 87 with AlarmManager

use of android.app.AlarmManager in project run-wallet-android by runplay.

the class AppService method onStartCommand.

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    super.onStartCommand(intent, flags, startId);
    if (SERVICE == null) {
        SERVICE = this;
        ensureStartups(getBaseContext());
        TorHelper.init(this, null);
        Intent service = new Intent(this, OnAlarmReceiver.class);
        PendingIntent pintent = PendingIntent.getService(this, 0, service, 0);
        AlarmManager alarm = (AlarmManager) this.getSystemService(Service.ALARM_SERVICE);
        // Start every 30 seconds
        alarm.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), Cal.HOURS_1_IN_MILLIS, pintent);
        IntentFilter afilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
        areceiver = new OnAlarmReceiver();
        // IntentFilter aofilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
        // aoreceiver = new OnAlarmReceiver();
        IntentFilter filter = new IntentFilter(Intent.ACTION_BOOT_COMPLETED);
        receiver = new OnBootReceiver();
        IntentFilter bfilter = new IntentFilter("android.intent.action.QUICKBOOT_POWERON");
        breceiver = new OnBootReceiver();
        IntentFilter ubfilter = new IntentFilter(Intent.ACTION_USER_PRESENT);
        ubreceiver = new OnUserPresentReceiver();
        registerReceiver(areceiver, afilter);
        // registerReceiver(aoreceiver, aofilter);
        registerReceiver(receiver, filter);
        registerReceiver(breceiver, bfilter);
        registerReceiver(ubreceiver, ubfilter);
        // removed for now, will be coming back with future Friend transfers feature
        // ContactsObserver contentObserver = new ContactsObserver();
        // this.getContentResolver().registerContentObserver (ContactsContract.Contacts.CONTENT_URI, true, contentObserver);
        startSyncsHandler.postDelayed(new Runnable() {

            public void run() {
                AppService.startRegularRefresh();
                syncDataHandler.postDelayed(syncDataThread, 10000);
            }
        }, 2000);
    }
    // ensureForegroundService();
    return START_STICKY;
}
Also used : IntentFilter(android.content.IntentFilter) AlarmManager(android.app.AlarmManager) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 88 with AlarmManager

use of android.app.AlarmManager in project vlc-android by videolan.

the class BootupReceiver method scheduleRecommendationUpdate.

private void scheduleRecommendationUpdate(Context context) {
    AlarmManager alarmManager = (AlarmManager) context.getApplicationContext().getSystemService(Context.ALARM_SERVICE);
    Intent recommendationIntent = new Intent(context, RecommendationsService.class);
    PendingIntent alarmIntent = PendingIntent.getService(context, 0, recommendationIntent, 0);
    alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, INITIAL_DELAY, AlarmManager.INTERVAL_HOUR, alarmIntent);
}
Also used : AlarmManager(android.app.AlarmManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 89 with AlarmManager

use of android.app.AlarmManager in project vlc-android by videolan.

the class AdvOptionsDialog method setSleep.

public static void setSleep(Calendar time) {
    final AlarmManager alarmMgr = (AlarmManager) VLCApplication.getAppContext().getSystemService(Context.ALARM_SERVICE);
    final Intent intent = new Intent(VLCApplication.SLEEP_INTENT);
    final PendingIntent sleepPendingIntent = PendingIntent.getBroadcast(VLCApplication.getAppContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    if (time != null)
        alarmMgr.set(AlarmManager.RTC_WAKEUP, time.getTimeInMillis(), sleepPendingIntent);
    else
        alarmMgr.cancel(sleepPendingIntent);
    VLCApplication.sPlayerSleepTime = time;
}
Also used : AlarmManager(android.app.AlarmManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 90 with AlarmManager

use of android.app.AlarmManager in project Slide by ccrama.

the class AutoCacheScheduler method cancel.

public void cancel(Context c) {
    AlarmManager manager = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE);
    manager.cancel(pendingIntent);
}
Also used : AlarmManager(android.app.AlarmManager)

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