List of usage examples for android.app AlarmManager RTC_WAKEUP
int RTC_WAKEUP
To view the source code for android.app AlarmManager RTC_WAKEUP.
Click Source Link
From source file:com.ekasoft.promoexito.MyActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(com.ekasoft.promoexito.R.layout.activity_my); Settings.set(this, "promo_order", "false"); if (!Settings.isKey(this, "install")) { Calendar cal = Calendar.getInstance(); Intent intent = new Intent(this, ServiceWithWebView.class); PendingIntent pintent = PendingIntent.getService(this, 0, intent, 0); AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 24 * 60 * 60 * 1000, pintent); Intent intent2 = new Intent(MyActivity.this, InstallPromoActivity.class); startActivity(intent2);//from w w w. j a v a2 s .c om finish(); } ActionBar ab = getSupportActionBar(); ab.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#ffe800"))); ab.setIcon(com.ekasoft.promoexito.R.drawable.bar); ab.setLogo(com.ekasoft.promoexito.R.drawable.bar); ab.setDisplayUseLogoEnabled(true); ab.setHomeAsUpIndicator(com.ekasoft.promoexito.R.drawable.bar); ab.setDisplayHomeAsUpEnabled(true); ab.setTitle(""); ActiveAndroid.initialize(this); mAdView = (AdView) findViewById(com.ekasoft.promoexito.R.id.ad_view); AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR) //.addTestDevice("4CBD3F38AF88E4EFA5FC4FB8B02D8D73") .build(); mAdView.loadAd(adRequest); listPromo = new FragmentListPromo(); listCategories = new CategorysFragment(); getSupportFragmentManager().beginTransaction() .add(com.ekasoft.promoexito.R.id.fragment_container, listPromo).commit(); }
From source file:com.metinkale.prayerapp.vakit.AlarmReceiver.java
public static void setAlarm(Context c, Alarm alarm) { AlarmManager am = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(c, WakefulReceiver.class); if (alarm != null) { i.putExtra("json", alarm.toString()); int id = alarm.hashCode(); PendingIntent service = PendingIntent.getBroadcast(c, id, i, PendingIntent.FLAG_UPDATE_CURRENT); am.cancel(service);//from w ww .j a va2 s.c o m App.setExact(am, AlarmManager.RTC_WAKEUP, alarm.time, service); } }
From source file:de.appplant.cordova.plugin.notification.NotificationWrapper.java
/** * Schedule new notification/* www . j ava 2 s . com*/ */ public void schedule(Options options) { long triggerTime = options.getDate(); persist(options.getId(), options.getJSONObject()); //Intent is called when the Notification gets fired Intent intent = new Intent(context, receiver).setAction("" + options.getId()).putExtra(OPTIONS, options.getJSONObject().toString()); AlarmManager am = getAlarmManager(); PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); am.set(AlarmManager.RTC_WAKEUP, triggerTime, pi); }
From source file:mobile.tiis.appv2.postman.RoutineAlarmReceiver.java
/** * This part starts the service that checks every 7 days for changes to doses, nonvacinationreasons and tables like these * * @param context/*from w ww . j av a2 s . c om*/ */ public static void setAlarmWeeklyUpdateBaseTables(Context context) { if (alarmMgr == null) alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent childChanges = new Intent(context, RoutineAlarmReceiver.class); childChanges.putExtra("weeklyUpdateBaseTables", true); weeklyUpdateBaseTables = PendingIntent.getBroadcast(context, 333, childChanges, PendingIntent.FLAG_UPDATE_CURRENT); alarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP, Calendar.getInstance().getTimeInMillis() + 604800000, 604800000, weeklyUpdateBaseTables); }
From source file:com.github.notizklotz.derbunddownloader.download.AutomaticIssueDownloadAlarmManager.java
private void registerAlarm(PendingIntent pendingIntent) { String autoDownloadTime = Settings.getAutoDownloadTime(context); if (!StringUtils.hasText(autoDownloadTime)) { throw new IllegalStateException("AutoDownloadTime is not set"); }/* w w w . j a v a 2 s . c o m*/ final Integer[] hourMinute = TimePickerPreference.toHourMinuteIntegers(autoDownloadTime); final Calendar nextAlarm = calculateNextAlarm(hourMinute[0], hourMinute[1]); // Make sure wakeup trigger is exact across all API versions. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { alarmManager.setExact(AlarmManager.RTC_WAKEUP, nextAlarm.getTimeInMillis(), pendingIntent); } else { alarmManager.set(AlarmManager.RTC_WAKEUP, nextAlarm.getTimeInMillis(), pendingIntent); } Settings.updateNextWakeup(context, nextAlarm.getTime()); }
From source file:org.ounl.lifelonglearninghub.nfcecology.scheduler.SampleAlarmReceiver.java
/** * Sets an alarm/*from w w w.j av a 2 s.c o m*/ * @param context */ public void setAlarm(Context context) { Log.d(CLASSNAME, "setAlarm"); alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, SampleAlarmReceiver.class); alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.add(Calendar.MINUTE, iMinsss); Log.d(CLASSNAME, "Setting alarm at " + calendar.getTime()); alarmMgr.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), alarmIntent); ComponentName receiver = new ComponentName(context, SampleBootReceiver.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); }
From source file:com.ayogo.cordova.notification.ScheduledNotificationManager.java
public ScheduledNotification scheduleNotification(String title, JSONObject options) { LOG.v(NotificationPlugin.TAG, "scheduleNotification: " + title); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); ScheduledNotification notification = new ScheduledNotification(title, options); long alarmTime = notification.at; if (alarmTime != 0) { //0 = uninitialized. saveNotification(notification);/* w ww.j ava 2s . co m*/ LOG.v(NotificationPlugin.TAG, "create Intent: " + notification.tag); Intent intent = new Intent(context, TriggerReceiver.class); intent.setAction(notification.tag); PendingIntent pi = PendingIntent.getBroadcast(context, INTENT_REQUEST_CODE, intent, PendingIntent.FLAG_CANCEL_CURRENT); LOG.v(NotificationPlugin.TAG, "schedule alarm for: " + alarmTime); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { alarmManager.setExact(AlarmManager.RTC_WAKEUP, alarmTime, pi); } else { alarmManager.set(AlarmManager.RTC_WAKEUP, alarmTime, pi); } } else { // No "at", trigger the notification right now. showNotification(notification); } return notification; }
From source file:edu.mit.media.realityanalysis.fieldtest.MainPipeline.java
@Override public void onCreate() { super.onCreate(); String password = getDataPassword(this); // If the user hasn't logged in yet, we need to stop the service // NOTE: this currently doesn't work properly because we're just using the default password (changeme) if (password == null || password == "") { Intent loginIntent = new Intent(this, LoginActivity.class); startActivity(loginIntent);/*w w w .ja v a 2 s.c o m*/ this.stopSelf(); } else { setEncryptionPassword(getDataPassword(this).toCharArray()); } //Setup the notification service to run periodically Intent notificationIntent = new Intent(this, NotificationService.class); PendingIntent notificationPendingIntent = PendingIntent.getService(this, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), AlarmManager.INTERVAL_HALF_HOUR, notificationPendingIntent); }
From source file:de.geeksfactory.opacclient.reminder.ReminderCheckService.java
@Override public int onStartCommand(Intent intent, int flags, int startid) { if (ACTION_SNOOZE.equals(intent.getAction())) { Intent i = new Intent(ReminderCheckService.this, ReminderAlarmReceiver.class); PendingIntent sender = PendingIntent.getBroadcast(ReminderCheckService.this, OpacClient.BROADCAST_REMINDER, i, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Log.i("ReminderCheckService", "Opac App Service: Quick repeat"); // Run again in 1 day am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (1000 * 3600 * 24), sender); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(OpacClient.NOTIF_ID); } else {// ww w .java 2 s .com SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(ReminderCheckService.this); notification_on = sp.getBoolean("notification_service", false); long waittime = (1000 * 3600 * 5); boolean executed = false; ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null) { if (!sp.getBoolean("notification_service_wifionly", false) || networkInfo.getType() == ConnectivityManager.TYPE_WIFI || networkInfo.getType() == ConnectivityManager.TYPE_ETHERNET) { executed = true; new CheckTask().execute(); } else { waittime = (1000 * 1800); } } else { waittime = (1000 * 1800); } if (!notification_on) { waittime = (1000 * 3600 * 12); } Intent i = new Intent(ReminderCheckService.this, ReminderAlarmReceiver.class); PendingIntent sender = PendingIntent.getBroadcast(ReminderCheckService.this, OpacClient.BROADCAST_REMINDER, i, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + waittime, sender); if (!executed) { stopSelf(); } } return START_NOT_STICKY; }
From source file:cn.apputest.ctria.service.UploadFailRecordService.java
public static void setServiceAlarm(Context context) { Log.i("ServiceUtil-AlarmManager", "invokeTimerPOIService wac called.."); PendingIntent alarmSender = null;/*w w w . ja va 2 s.c o m*/ Intent startIntent = new Intent(context, UploadFailRecordService.class); startIntent.setAction(Constants.POI_SERVICE_ACTION); try { alarmSender = PendingIntent.getService(context, 0, startIntent, PendingIntent.FLAG_UPDATE_CURRENT); } catch (Exception e) { Log.i("ServiceUtil-AlarmManager", "failed to start " + e.toString()); } AlarmManager am = (AlarmManager) context.getSystemService(Activity.ALARM_SERVICE); am.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), Constants.ELAPSED_TIME_F, alarmSender); }