List of usage examples for android.app AlarmManager INTERVAL_HALF_HOUR
long INTERVAL_HALF_HOUR
To view the source code for android.app AlarmManager INTERVAL_HALF_HOUR.
Click Source Link
From source file:org.metawatch.manager.Monitors.java
static void startAlarmTicker(Context context) { if (Preferences.logging) Log.d(MetaWatch.TAG, "startAlarmTicker()"); alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); intent = new Intent(context, AlarmReceiver.class); intent.putExtra("action_update", "update"); sender = PendingIntent.getBroadcast(context, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT); alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, 0, AlarmManager.INTERVAL_HALF_HOUR, sender); }
From source file:org.voidsink.anewjkuapp.utils.AppUtils.java
public static void updateSyncAlarm(Context context, boolean reCreateAlarm) { boolean mIsCalendarSyncEnabled = false; boolean mIsKusssSyncEnable = false; boolean mIsMasterSyncEnabled = ContentResolver.getMasterSyncAutomatically(); if (mIsMasterSyncEnabled) { final Account mAccount = getAccount(context); if (mAccount != null) { mIsCalendarSyncEnabled = ContentResolver.getSyncAutomatically(mAccount, CalendarContractWrapper.AUTHORITY()); mIsKusssSyncEnable = ContentResolver.getSyncAutomatically(mAccount, KusssContentContract.AUTHORITY); }//from www. jav a2s . co m } Log.d(TAG, String.format("MasterSync=%b, CalendarSync=%b, KusssSync=%b", mIsMasterSyncEnabled, mIsCalendarSyncEnabled, mIsKusssSyncEnable)); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, SyncAlarmService.class); intent.putExtra(Consts.ARG_UPDATE_CAL, !mIsCalendarSyncEnabled); intent.putExtra(Consts.ARG_UPDATE_KUSSS, !mIsKusssSyncEnable); intent.putExtra(Consts.ARG_RECREATE_SYNC_ALARM, true); intent.putExtra(Consts.SYNC_SHOW_PROGRESS, true); // check if pending intent exists reCreateAlarm = reCreateAlarm || (PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_NO_CREATE) == null); // new pending intent PendingIntent alarmIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); if (!mIsMasterSyncEnabled || !mIsCalendarSyncEnabled || !mIsKusssSyncEnable) { if (reCreateAlarm) { long interval = PreferenceWrapper.getSyncInterval(context) * DateUtils.HOUR_IN_MILLIS; // synchronize in half an hour am.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + AlarmManager.INTERVAL_HALF_HOUR, interval, alarmIntent); } } else { am.cancel(alarmIntent); } }
From source file:com.codename1.impl.android.AndroidImplementation.java
public void scheduleLocalNotification(LocalNotification notif, long firstTime, int repeat) { final Intent notificationIntent = new Intent(getContext(), LocalNotificationPublisher.class); notificationIntent.setAction(getContext().getApplicationInfo().packageName + "." + notif.getId()); notificationIntent.putExtra(LocalNotificationPublisher.NOTIFICATION, createBundleFromNotification(notif)); Intent contentIntent = new Intent(); if (getActivity() != null) { contentIntent.setComponent(getActivity().getComponentName()); }// w w w. j av a 2 s. co m contentIntent.putExtra("LocalNotificationID", notif.getId()); if (BACKGROUND_FETCH_NOTIFICATION_ID.equals(notif.getId()) && getBackgroundFetchListener() != null) { Context context = AndroidNativeUtil.getContext(); Intent intent = new Intent(context, BackgroundFetchHandler.class); //there is an bug that causes this to not to workhttps://code.google.com/p/android/issues/detail?id=81812 //intent.putExtra("backgroundClass", getBackgroundLocationListener().getName()); //an ugly workaround to the putExtra bug intent.setData( Uri.parse("http://codenameone.com/a?" + getBackgroundFetchListener().getClass().getName())); PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); notificationIntent.putExtra(LocalNotificationPublisher.BACKGROUND_FETCH_INTENT, pendingIntent); } else { contentIntent.setData( Uri.parse("http://codenameone.com/a?LocalNotificationID=" + Uri.encode(notif.getId()))); } PendingIntent pendingContentIntent = PendingIntent.getActivity(getContext(), 0, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT); notificationIntent.putExtra(LocalNotificationPublisher.NOTIFICATION_INTENT, pendingContentIntent); PendingIntent pendingIntent = PendingIntent.getBroadcast(getContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager) getContext().getSystemService(Context.ALARM_SERVICE); if (BACKGROUND_FETCH_NOTIFICATION_ID.equals(notif.getId())) { alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, firstTime, getPreferredBackgroundFetchInterval() * 1000, pendingIntent); } else { if (repeat == LocalNotification.REPEAT_NONE) { alarmManager.set(AlarmManager.RTC_WAKEUP, firstTime, pendingIntent); } else if (repeat == LocalNotification.REPEAT_MINUTE) { alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, firstTime, 60 * 1000, pendingIntent); } else if (repeat == LocalNotification.REPEAT_HOUR) { alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, firstTime, AlarmManager.INTERVAL_HALF_HOUR, pendingIntent); } else if (repeat == LocalNotification.REPEAT_DAY) { alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, firstTime, AlarmManager.INTERVAL_DAY, pendingIntent); } else if (repeat == LocalNotification.REPEAT_WEEK) { alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, firstTime, AlarmManager.INTERVAL_DAY * 7, pendingIntent); } } }