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.android.example.alwaysonstopwatch.StopwatchActivity.java
private void updateDisplayAndSetRefresh() { if (!mRunning) { return;/*ww w.ja va2 s .com*/ } incrementTimeSoFar(); int seconds = (int) (mTimeSoFar / 1000); final int minutes = seconds / 60; seconds = seconds % 60; setTimeView(minutes, seconds); if (!isAmbient()) { // In Active mode update directly via handler. long timeMs = System.currentTimeMillis(); long delayMs = ACTIVE_INTERVAL_MS - (timeMs % ACTIVE_INTERVAL_MS); Log.d(TAG, "NOT ambient - delaying by: " + delayMs); mActiveModeUpdateHandler.sendEmptyMessageDelayed(R.id.msg_update, delayMs); } else { // In Ambient mode update via AlarmManager. long timeMs = System.currentTimeMillis(); long delayMs = AMBIENT_INTERVAL_MS - (timeMs % AMBIENT_INTERVAL_MS); long triggerTimeMs = timeMs + delayMs; Log.d(TAG, "In ambient - trigger time: " + mDebugTimeFormat.format(triggerTimeMs)); mAmbientStateAlarmManager.cancel(mAmbientStatePendingIntent); mAmbientStateAlarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerTimeMs, mAmbientStatePendingIntent); } }
From source file:samson.AndroidNotifications.java
@Override protected Handle schedule(long when, Builder builder) { // pull the id of this notification based off the Builder's string id or an automatically // generated identifier final int id; try {/* ww w .java2s .co m*/ id = builder._data.containsKey(Notifications.ID) ? builder._data.get(Notifications.ID).hashCode() : getAutomaticIdentifier(); } catch (IllegalArgumentException exception) { log.error("Failed to find valid identifier to send notification with."); return null; } // build a simulated task stack so the back button works properly TaskStackBuilder stack = TaskStackBuilder.create(applicationContext).addParentStack(activityClass) .addNextIntent(new Intent(applicationContext, activityClass)); // create the notification builder Notification notification = new NotificationCompat.Builder(applicationContext).setAutoCancel(true) .setSmallIcon(builder._icon).setLargeIcon(getLargeIcon(builder)).setContentTitle(builder._title) .setContentText(builder._message) .setVibrate(builder._vibrate ? new long[] { 100, 200, 200, 200 } : new long[] {}) .setContentIntent(stack.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)).setWhen(when) .setStyle(new NotificationCompat.BigTextStyle().bigText(builder._message)).build(); // build the pending intent to pass to the alarm receiver final PendingIntent pending = PendingIntent.getBroadcast(applicationContext, id, new NotificationIntent(applicationContext, id, notification), 0); // register the pending notification id addNotification(id); // pass the intent to the alarm receiver alarmManager.set(AlarmManager.RTC_WAKEUP, when, pending); return new Handle() { @Override public void cancel() { notificationManager.cancel(id); alarmManager.cancel(pending); removeNotification(id); } }; }
From source file:townley.stuart.app.android.trekkinly.Notification_picker_class.java
public void setNotification() { NotificationItemClass notificationItemClass = new NotificationItemClass(); DataBaseHelper db = new DataBaseHelper(getActivity()); db.getWritableDatabase();/*from w w w .j av a 2 s . c o m*/ db.addNotification(notificationItemClass); db.upDateDataBaseNotification(notificationItemClass); db.getNotification(notificationItemClass); if (db.notification <= 0) { Toast.makeText(getActivity(), "Please set a time for the notification", Toast.LENGTH_SHORT).show(); } else { ComponentName receiver = new ComponentName(getActivity(), AlertClass.class); PackageManager pm = getActivity().getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); Intent intent = new Intent(getActivity(), AlertClass.class); AlarmManager alarmManager = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, db.notification, PendingIntent.getBroadcast( getActivity().getApplicationContext(), 1, intent, PendingIntent.FLAG_UPDATE_CURRENT)); Toast.makeText(getActivity(), "Notification issued", Toast.LENGTH_SHORT).show(); Log.d("Trekkinly", "AlarmNotification Called"); } }
From source file:com.adguard.android.service.FilterServiceImpl.java
@Override public void scheduleFiltersUpdate() { Intent alarmIntent = new Intent(AlarmReceiver.UPDATE_FILTER_ACTION); boolean isRunning = PendingIntent.getBroadcast(context, 0, alarmIntent, PendingIntent.FLAG_NO_CREATE) != null; if (!isRunning) { LOG.info("Starting scheduler of filters updating"); PendingIntent broadcastIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, UPDATE_INITIAL_PERIOD, AlarmManager.INTERVAL_HOUR, broadcastIntent);//from w w w . jav a2s . c o m } else { LOG.info("Filters update is running"); } }
From source file:org.roman.findme.MainActivity.java
void startLocationService() { // Intent intent = new Intent(this, AndroidLocationServices.class); // startService(intent); Intent intent = new Intent(this, AlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 1253, intent, PendingIntent.FLAG_CANCEL_CURRENT); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alarm.cancel(pendingIntent);//from w ww . j a v a 2 s . com alarm.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_HOUR, pendingIntent); }
From source file:com.chintans.venturebox.util.Utils.java
public static void setAlarm(Context context, long time, boolean trigger, boolean isRom) { Intent i = new Intent(context, NotificationAlarm.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pi = PendingIntent.getBroadcast(context, isRom ? ROM_ALARM_ID : GAPPS_ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.cancel(pi);// w ww .j av a 2s . c o m if (time > 0) { am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi); } }
From source file:com.example.gemswin.screencastrecevertest.MainActivity_Reciever.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_reciever); WifiManager wm = (WifiManager) getSystemService(WIFI_SERVICE); String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress()); TextView text = (TextView) findViewById(R.id.textView); planetList = new ArrayList<String>(); mTextureView = (TextureView)findViewById(R.id.textureView); mTextureView.setSurfaceTextureListener(this); mTextureView.requestLayout();// w ww. j a v a 2s . co m mTextureView.invalidate(); mTextureView.setOpaque(false); logout = (Button) findViewById(R.id.logout); cast = (Button) findViewById(R.id.castAsmaster); doubtbutton = (Button) findViewById(R.id.doubt); viewbutton = (Button) findViewById(R.id.viewdoubt); pref = new PrefManager(getApplicationContext()); text.setText(ip); logout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pref.logout(); Intent i = new Intent(MainActivity_Reciever.this, LoginActivity.class); startActivity(i); finish(); } }); cast.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new allowcast().execute(); } }); viewbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //pref.logout(); // LOOK HERE ASH /*Intent i = new Intent(MainActivity_Reciever.this,DoubtActivity.class); startActivity(i);*/ new viewdoubttask().execute(); } }); doubtbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //pref.logout(); // LOOK HERE ASH /*Intent i = new Intent(MainActivity_Reciever.this,DoubtActivity.class); startActivity(i);*/ DoubtBox(); } }); mTask = new ReceiverAsyncTask(this); mTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); Intent intent1 = new Intent(this, MyBroadcastReceiver.class); intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getBroadcast( getApplicationContext(), 234324243, intent1, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (10 * 1000), pendingIntent); }
From source file:com.nextgis.firereporter.ReporterService.java
public void ScheduleNextUpdate(Context context, long nMinTimeBetweenSend, boolean bEnergyEconomy) { if (context == null) return;/*from w w w .ja va 2 s .c o m*/ Intent intent = new Intent(ReporterService.ACTION_START); PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); // The update frequency should often be user configurable. This is not. long currentTimeMillis = System.currentTimeMillis(); long nextUpdateTimeMillis = currentTimeMillis + nMinTimeBetweenSend; Time nextUpdateTime = new Time(); nextUpdateTime.set(nextUpdateTimeMillis); AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); if (bEnergyEconomy) alarmManager.set(AlarmManager.RTC, nextUpdateTimeMillis, pendingIntent); else alarmManager.set(AlarmManager.RTC_WAKEUP, nextUpdateTimeMillis, pendingIntent); }
From source file:com.iitb.wicroft.EventAlarmReceiver.java
public static void schedule_event(Context context, RequestEvent e) { Intent intent = new Intent(context, EventAlarmReceiver.class); intent.putExtra("eventid", (int) e.event_id); Random r = new Random(); int i1 = r.nextInt(10000 - 0) + 0; PendingIntent sender = PendingIntent.getBroadcast(context, 123456 + i1, intent, PendingIntent.FLAG_UPDATE_CURRENT); String msg = "Schedule_dependency_event"; msg += "\n Scheduling " + e.event_id + "@ " + e.relative_time; long curr_time = System.currentTimeMillis(); long t = e.relative_time * 1000; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { MainActivity.am.setExact(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + t, sender); } else {/* w w w . j a va2 s. c om*/ MainActivity.am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + t, sender); } Log.d(Constants.LOGTAG, msg); if (MainActivity.debugging_on) { Calendar cal = Calendar.getInstance(); SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd"); Threads.writeToLogFile(MainActivity.debugfilename, format1.format(cal.getTime()) + " " + Utils.sdf.format(cal.getTime()) + msg); } }
From source file:com.gmail.at.faint545.fragments.QueueFragment.java
private void setRecurringAlarm() { if (getRemote().getRefreshInterval() != -1) { updateTime = Calendar.getInstance(); updateTime.setTimeZone(TimeZone.getTimeZone("GMT")); updateTime.set(Calendar.MINUTE, 1); Intent downloader = new Intent(getActivity(), AlarmReciever.class); downloader.putExtra("url", getRemote().buildURL()); downloader.putExtra("api", getRemote().getApiKey()); downloader.putExtra("messenger", new Messenger(handler)); PendingIntent recurringDownload = PendingIntent.getBroadcast(getActivity(), 0, downloader, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager alarms = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE); alarms.setInexactRepeating(AlarmManager.RTC_WAKEUP, updateTime.getTimeInMillis(), getRemote().getRefreshInterval(), recurringDownload); } else {// ww w. j a va 2 s. c o m downloadQueue(null); } }