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:townley.stuart.app.android.trekkinly.AlertClass.java
@Override public void onReceive(final Context context, Intent intent) { NotificationItemClass notificationItemClass = new NotificationItemClass(); DataBaseHelper db = new DataBaseHelper(context); db.getWritableDatabase();/*from w w w . jav a 2 s . co m*/ db.getNotification(notificationItemClass); if (db.notification <= System.currentTimeMillis()) { createNotification(context, "Something is missing!", "Click here for more details!", "Alert"); ComponentName receiver = new ComponentName(context, AlertClass.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); intent = new Intent(context, AlertClass.class); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(PendingIntent.getBroadcast(context.getApplicationContext(), 1, intent, PendingIntent.FLAG_UPDATE_CURRENT)); } else if (db.notification > System.currentTimeMillis()) { intent = new Intent(context, AlertClass.class); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, db.notification, PendingIntent .getBroadcast(context.getApplicationContext(), 1, intent, PendingIntent.FLAG_UPDATE_CURRENT)); } }
From source file:com.bhb27.isu.services.BootBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { // only run if the app has run before and main has extracted asserts String action = intent.getAction(); boolean run_boot = Tools.getBoolean("run_boot", false, context); boolean rootAccess = Tools.rootAccess(context); if (Intent.ACTION_BOOT_COMPLETED.equals(action) && rootAccess && run_boot) { Log.d(TAG, " Started action " + action + " run_boot " + run_boot); if (Tools.getBoolean("prop_run", false, context) && Tools.getBoolean("apply_props", false, context)) ContextCompat.startForegroundService(context, new Intent(context, PropsService.class)); ContextCompat.startForegroundService(context, new Intent(context, BootService.class)); if (Tools.getBoolean("apply_su", false, context) && Tools.SuVersionBool(Tools.SuVersion(context))) { AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent serviceIntent = new Intent("com.bhb27.isu.services.SuServiceReceiver.RUN"); serviceIntent.putExtra("RUN", 100); serviceIntent.setClass(context, SuServiceReceiver.class); serviceIntent.setAction("RUN"); PendingIntent pi = PendingIntent.getBroadcast(context, 100, serviceIntent, PendingIntent.FLAG_UPDATE_CURRENT); am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + Integer.valueOf(Tools.readString("apply_su_delay", "0", context)), pi); }// w w w . j av a2 s .c o m } else Log.d(TAG, "Not Started action " + action + " rootAccess " + rootAccess + " run_boot " + run_boot); }
From source file:com.github.rutvijkumar.twittfuse.Util.java
public static final void scheduleAlarm(Activity activity) { // Construct an intent that will execute the AlarmReceiver Intent intent = new Intent(activity.getApplicationContext(), OfflineTweetAlarmReceiver.class); // Create a PendingIntent to be triggered when the alarm goes off final PendingIntent pIntent = PendingIntent.getBroadcast(activity, OfflineTweetAlarmReceiver.REQUEST_CODE, intent, PendingIntent.FLAG_UPDATE_CURRENT); // Setup periodic alarm every 10 seconds long firstMillis = System.currentTimeMillis(); // first run of alarm is // immediate//from www .j a v a2 s . c om int intervalMillis = 10000; // 10 seconds AlarmManager alarm = (AlarmManager) activity.getSystemService(Context.ALARM_SERVICE); alarm.setInexactRepeating(AlarmManager.RTC_WAKEUP, firstMillis, intervalMillis, pIntent); }
From source file:me.futuretechnology.blops.ui.HomeActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // startService(new Intent(getApplication(), CleanupService.class)); // if (sharedPrefs.getBoolean(Keys.FIRST_RUN, true)) // {//from w w w . ja v a 2 s . com // Editor editor = sharedPrefs.edit(); // editor.putBoolean(Keys.FIRST_RUN, false); // editor.apply(); // schedule cleanup service // FIXME temp fix Time time = new Time(); time.setToNow(); // time.hour = 3; // time.minute = 0; // time.second = 0; // ++time.monthDay; // time.normalize(true); Intent intent = new Intent(getApplication(), OnAlarmReceiver.class); intent.setAction(OnAlarmReceiver.ACTION_CLEANUP); AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, time.toMillis(true), PendingIntent.getBroadcast(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)); // } EventBus.getDefault().register(this); }
From source file:com.daiv.android.twitter.services.TrimDataService.java
public void setNextTrim(Context context) { AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); long now = new Date().getTime(); long alarm = now + AlarmManager.INTERVAL_DAY; Log.v("alarm_date", "auto trim " + new Date(alarm).toString()); PendingIntent pendingIntent = PendingIntent.getService(context, TRIM_ID, new Intent(context, TrimDataService.class), 0); am.set(AlarmManager.RTC_WAKEUP, alarm, pendingIntent); }
From source file:com.brayanarias.alarmproject.receiver.AlarmReceiver.java
private static void setAlarmCumple(Context context) { PendingIntent pendingIntent = null;//from ww w . j a v a 2 s.c o m Intent intent = new Intent(context, AlarmService.class); intent.putExtra(Constant.alarmIdKey, 2809); intent.putExtra(Constant.alarmNameKey, "Feliz cumple mamita"); pendingIntent = PendingIntent.getService(context, 2809, intent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = getAlarmManager(context); Calendar actual = Calendar.getInstance(); actual.set(Calendar.MONTH, 8); actual.set(Calendar.DAY_OF_MONTH, 28); actual.set(Calendar.SECOND, 0); actual.set(Calendar.MILLISECOND, 0); actual.set(Calendar.HOUR, 5); actual.set(Calendar.AM_PM, Calendar.AM); actual.set(Calendar.MINUTE, 0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { AlarmManager.AlarmClockInfo clockInfo = new AlarmManager.AlarmClockInfo(actual.getTimeInMillis(), pendingIntent); alarmManager.setAlarmClock(clockInfo, pendingIntent); } else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { alarmManager.setExact(AlarmManager.RTC_WAKEUP, actual.getTimeInMillis(), pendingIntent); } else { alarmManager.set(AlarmManager.RTC_WAKEUP, actual.getTimeInMillis(), pendingIntent); } }
From source file:cat.wuyingren.whatsannoy.utils.SystemUtils.java
public static long createAlarm(Context context, int frequency, int alarmID) { Log.w("UTILS", "createAlarm()"); Intent alarmIntent = new Intent(context, Alarm.class); alarmIntent.putExtra(Alarm.PREF_ALARM_ID, alarmID); PendingIntent pi = PendingIntent.getBroadcast(context, -1, alarmIntent, 0); Random r = new Random(); int addMin = r.nextInt(frequency); if (addMin < 1) { addMin = 1;/*from w w w . ja va 2 s .c o m*/ } Calendar c = Calendar.getInstance(); c.add(Calendar.MINUTE, addMin); c.add(Calendar.SECOND, 0); AlarmManager alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmMgr.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), pi); return c.getTimeInMillis(); }
From source file:org.nerdcircus.android.klaxon.Notifier.java
@Override public void onReceive(Context context, Intent intent) { NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); AlarmManager am = (AlarmManager) context.getSystemService(Activity.ALARM_SERVICE); if (intent.getAction().equals(Pager.PAGE_RECEIVED)) { Log.d(TAG, "new page received. notifying."); //get subject line of page, for notification. Cursor cursor = context.getContentResolver().query(intent.getData(), new String[] { Pager.Pages._ID, Pager.Pages.SUBJECT }, null, null, null); cursor.moveToFirst();//from w w w.j av a2 s .c o m String page_subj = cursor.getString(cursor.getColumnIndex(Pager.Pages.SUBJECT)); Notification n = getNotification(context, page_subj); n.sound = null; //no noise initially. wait for the delayed ANNOY action below. nm.notify(R.string.notify_page, n); Intent i = new Intent(Pager.ANNOY_ACTION); //we cant use data here, because it makes the silencing fail. i.putExtra("notification_text", page_subj); PendingIntent annoyintent = PendingIntent.getBroadcast(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Log.d(TAG, "notifcation interval: " + prefs.getString("notification_interval", "unknown")); long repeat_interval_ms = Integer.valueOf(prefs.getString("notification_interval", "20000")) .longValue(); Log.d(TAG, "notifcation interval: " + repeat_interval_ms); // 500 ms delay, to prevent the regular text message noise from stomping on us. am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 500, repeat_interval_ms, annoyintent); } else if (intent.getAction().equals(Pager.SILENCE_ACTION)) { Log.d(TAG, "cancelling the notification..."); Intent i = new Intent(Pager.ANNOY_ACTION); PendingIntent annoyintent = PendingIntent.getBroadcast(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); am.cancel(annoyintent); nm.cancel(R.string.notify_page); } else if (intent.getAction().equals(Pager.ANNOY_ACTION)) { Log.e(TAG, "got annoy intent. annoying."); //just be annoying. Notification n = getNotification(context, intent.getStringExtra("notification_text")); nm.notify(R.string.notify_page, n); } else if (intent.getAction().equals("org.nerdcircus.android.klaxon.REPLY_SENT")) { //a reply was sent. update state in the db. if (Activity.RESULT_OK == getResultCode()) { Log.d(TAG, "reply successful. updating ack status.."); //result was sent. update state. updateAckStatus(context, intent.getData(), intent.getIntExtra(Pager.EXTRA_NEW_ACK_STATUS, 0)); } else { Log.e(TAG, "reply failed!!! doing nothing."); } } else { Log.e(TAG, "Uncaught Action:" + intent.getAction()); } }
From source file:com.mech.tech.meet.activities.scenario.MainActivity.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override/*from w ww.j a va2s. c o m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); int currentapiVersion = android.os.Build.VERSION.SDK_INT; if (currentapiVersion >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(getResources().getColor(R.color.material_wala_deep_blue)); } Calendar cal = Calendar.getInstance(); cal.add(Calendar.SECOND, 10); Intent intent = new Intent(this, MyNotificationService.class); PendingIntent pintent = PendingIntent.getService(this, 0, intent, 0); AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 36000 * 1000 * 2, pintent); startService(new Intent(getBaseContext(), MyNotificationService.class)); mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager() .findFragmentById(R.id.navigation_drawer); mTitle = getTitle(); // Set up the drawer. mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); }
From source file:br.ajmarques.cordova.plugin.localnotification.LocalNotification.java
/** * Set an alarm.//from w w w.ja v a 2s . com * * @param options * The options that can be specified per alarm. */ public static void add(Options options) { long triggerTime = options.getDate(); Intent intent = new Intent(context, Receiver.class).setAction("" + options.getId()) .putExtra(Receiver.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); }