Java Code Examples for android.content.Intent#ACTION_TIME_CHANGED
The following examples show how to use
android.content.Intent#ACTION_TIME_CHANGED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GattServerActivity.java From sample-bluetooth-le-gattserver with Apache License 2.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { byte adjustReason; switch (intent.getAction()) { case Intent.ACTION_TIME_CHANGED: adjustReason = TimeProfile.ADJUST_MANUAL; break; case Intent.ACTION_TIMEZONE_CHANGED: adjustReason = TimeProfile.ADJUST_TIMEZONE; break; default: case Intent.ACTION_TIME_TICK: adjustReason = TimeProfile.ADJUST_NONE; break; } long now = System.currentTimeMillis(); notifyRegisteredDevices(now, adjustReason); updateLocalUi(now); }
Example 2
Source File: TimeObserverService.java From GeometricWeather with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action == null) { return; } switch (action) { case Intent.ACTION_TIME_TICK: doRefreshWork(); break; case Intent.ACTION_TIME_CHANGED: case Intent.ACTION_TIMEZONE_CHANGED: lastUpdateNormalViewTime = -1; doRefreshWork(); break; } }
Example 3
Source File: GeofencingConsistencyReceiver.java From mobile-messaging-sdk-android with Apache License 2.0 | 6 votes |
@Override public void onReceive(final Context context, final Intent intent) { if (!GeofencingHelper.isGeoActivated(context)) { return; } final String action = intent.getAction(); if (StringUtils.isBlank(action)) { return; } switch (action) { case NETWORK_PROVIDER_ENABLED_ACTION: case SCHEDULED_GEO_REFRESH_ACTION: case Intent.ACTION_TIME_CHANGED: case Intent.ACTION_PACKAGE_DATA_CLEARED: case SCHEDULED_GEO_EXPIRE_ACTION: GeofencingConsistencyIntentService.enqueueWork(context, intent); break; } }
Example 4
Source File: LiveWallpaperService.java From Mysplash with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (!TextUtils.isEmpty(action)) { switch (intent.getAction()) { case Intent.ACTION_TIME_TICK: if (System.currentTimeMillis() - lastReadSettingsTime >= 15 * MINUTE) { manager = LiveWallpaperOptionManager.getInstance(context); lastReadSettingsTime = System.currentTimeMillis(); } if (isRefreshTime()) { updateWallpaper(context); } break; case Intent.ACTION_TIME_CHANGED: case Intent.ACTION_TIMEZONE_CHANGED: manager = LiveWallpaperOptionManager.getInstance(context); lastReadSettingsTime = System.currentTimeMillis(); updateWallpaper(context); break; } } }
Example 5
Source File: ColorDisplayService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public void onStart() { final IntentFilter intentFilter = new IntentFilter(Intent.ACTION_TIME_CHANGED); intentFilter.addAction(Intent.ACTION_TIMEZONE_CHANGED); getContext().registerReceiver(mTimeChangedReceiver, intentFilter); mStartTime = mController.getCustomStartTime(); mEndTime = mController.getCustomEndTime(); mLastActivatedTime = mController.getLastActivatedTime(); // Force an update to initialize state. updateActivated(); }
Example 6
Source File: TimeReceiver.java From DevUtils with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { try { String action = intent.getAction(); // 打印当前触发的广播 LogPrintUtils.dTag(TAG, "onReceive Action: " + action); // 判断类型 switch (action) { case Intent.ACTION_TIMEZONE_CHANGED: // 时区改变 if (sListener != null) { sListener.onTimeZoneChanged(); } break; case Intent.ACTION_TIME_CHANGED: // 设置时间 if (sListener != null) { sListener.onTimeChanged(); } break; case Intent.ACTION_TIME_TICK: // 每分钟调用 if (sListener != null) { sListener.onTimeTick(); } break; } } catch (Exception e) { LogPrintUtils.eTag(TAG, e, "onReceive"); } }
Example 7
Source File: TimeTickReceiver.java From prayer-times-android with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { String action = intent == null ? null : intent.getAction(); if (action == null) action = Intent.ACTION_TIME_TICK; switch (action) { case Intent.ACTION_SCREEN_OFF: { mCtx.unregisterReceiver(this); mCtx.registerReceiver(this, mScreenOnOffFilter); break; } case Intent.ACTION_SCREEN_ON: { mCtx.unregisterReceiver(this); mCtx.registerReceiver(this, mScreenOnOffFilter); mCtx.registerReceiver(this, mTimeTickFilter); mCtx.registerReceiver(this, mTimeChangedFilter); } case Intent.ACTION_USER_PRESENT: case Intent.ACTION_TIME_CHANGED: case Intent.ACTION_TIME_TICK: default: { int timeTick = (int) (System.currentTimeMillis() / 1000 / 60); if (LAST_TIME_TICK != timeTick) { InternalBroadcastReceiver.sender(mCtx).sendTimeTick(); LAST_TIME_TICK = timeTick; } break; } } }
Example 8
Source File: GeofencingConsistencyIntentService.java From mobile-messaging-sdk-android with Apache License 2.0 | 5 votes |
private void handleGeoConsistencyAction(Context context, Intent intent, String action) { switch (action) { /* * NETWORK_PROVIDER_ENABLED_ACTION - scheduled 15 seconds after NETWORK_PROVIDER is enabled. Starts monitoring geofences from storage if geo is enabled. * SCHEDULED_GEO_REFRESH_ACTION - scheduled to start when campaign needs to be started and area monitored * Intent.ACTION_TIME_CHANGED - triggered when system date/time is changed manually (set by user in settings), need to go over all campaigns in this case. */ case NETWORK_PROVIDER_ENABLED_ACTION: case SCHEDULED_GEO_REFRESH_ACTION: case Intent.ACTION_TIME_CHANGED: startGeoMonitoringFromScratch(context); break; /* * This action gets called whenever user deletes data from some app, and we're interested in clear Play Services cleared event * because all registered geofences stop being monitored by GPS in that case. */ case Intent.ACTION_PACKAGE_DATA_CLEARED: final Uri data = intent.getData(); if (data != null && GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE.equals(data.getSchemeSpecificPart())) { startGeoMonitoringFromScratch(context); } break; /* * Scheduled to be invoked when first area from geo storage needs to expire. In that case GPS stop monitoring areas, but we * also need to be aware of this event. */ case SCHEDULED_GEO_EXPIRE_ACTION: geofencingHelper(context).removeExpiredAreas(); break; } }
Example 9
Source File: TimeTickReceiver.java From prayer-times-android with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { String action = intent == null ? null : intent.getAction(); if (action == null) action = Intent.ACTION_TIME_TICK; switch (action) { case Intent.ACTION_SCREEN_OFF: { mCtx.unregisterReceiver(this); mCtx.registerReceiver(this, mScreenOnOffFilter); break; } case Intent.ACTION_SCREEN_ON: { mCtx.unregisterReceiver(this); mCtx.registerReceiver(this, mScreenOnOffFilter); mCtx.registerReceiver(this, mTimeTickFilter); mCtx.registerReceiver(this, mTimeChangedFilter); } case Intent.ACTION_USER_PRESENT: case Intent.ACTION_TIME_CHANGED: case Intent.ACTION_TIME_TICK: default: { int timeTick = (int) (System.currentTimeMillis() / 1000 / 60); if (LAST_TIME_TICK != timeTick) { InternalBroadcastReceiver.sender(mCtx).sendTimeTick(); LAST_TIME_TICK = timeTick; } break; } } }
Example 10
Source File: TimeView.java From AcDisplay with GNU General Public License v2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { switch (intent.getAction()) { case Intent.ACTION_TIME_TICK: case Intent.ACTION_TIME_CHANGED: case Intent.ACTION_TIMEZONE_CHANGED: updateClock(); break; } }
Example 11
Source File: TimeChangeObserver.java From opentasks with Apache License 2.0 | 5 votes |
/** * Creates a new {@link TimeChangeObserver}. * * @param context * A {@link Context} * @param listener * The {@link TimeChangeListener} to notify of any events, */ public TimeChangeObserver(Context context, TimeChangeListener listener) { IntentFilter intentFilter = new IntentFilter(Intent.ACTION_TIME_CHANGED); intentFilter.addAction(Intent.ACTION_TIMEZONE_CHANGED); mAppContext = context.getApplicationContext(); mAppContext.registerReceiver(this, intentFilter); mListener = listener; }
Example 12
Source File: AlarmsService.java From OmniList with GNU Affero General Public License v3.0 | 4 votes |
@Override public int onStartCommand(Intent intent, int flags, int startId) { String action = intent.getAction(); if (action == null) { throw new IllegalArgumentException("Illegal action"); } switch (action){ case Intent.ACTION_BOOT_COMPLETED: LogUtils.d("onStartCommand: " + "android.intent.action.BOOT_COMPLETED"); alarmsManager.registerAllAlarms(); break; case Intent.ACTION_TIMEZONE_CHANGED: LogUtils.d("onStartCommand: " + "android.intent.action.TIMEZONE_CHANGED"); alarmsManager.registerAllAlarms(); break; case Intent.ACTION_LOCALE_CHANGED: LogUtils.d("onStartCommand: " + "android.intent.action.LOCALE_CHANGED"); alarmsManager.registerAllAlarms(); break; case Intent.ACTION_TIME_CHANGED: LogUtils.d("onStartCommand: " + "android.intent.action.TIME_SET"); alarmsManager.registerAllAlarms(); break; } int code = -1; try { code = intent.getIntExtra(Constants.EXTRA_CODE, -1); switch (action) { case PresentationToModelIntents.ACTION_REQUEST_SNOOZE: alarmsManager.snooze(code, null); break; case PresentationToModelIntents.ACTION_REQUEST_DISMISS: alarmsManager.dismiss(code); break; } } catch (AlarmNotFoundException e) { LogUtils.d("onStartCommand: Alarm not found [ code:" + code + "]"); } return START_NOT_STICKY; }
Example 13
Source File: ActionService.java From opentasks with Apache License 2.0 | 4 votes |
private TaskAction resolveAction(String action) { switch (action) { case ACTION_COMPLETE: return new Composite( // remove the notification, without storing the change yet new CancelNotificationAction(), // create undo notification new PostUndoAction(), // create delayed action to finish the completion new DelayedAction(ACTION_FINISH_COMPLETE, UNDO_TIMEOUT_MILLIS)); case ACTION_PIN_TASK: // just pin, let TaskNotificationService do the rest return new PinAction(true); case ACTION_UNPIN: // unpin, let TaskNotificationService do the rest return new PinAction(false); case ACTION_OPEN_TASK: // just open the task return new OpenAction(); case ACTION_OPEN_TASK_CANCEL_NOTIFICATION: // just open the task and cancel the notification return new Composite(new OpenAction(), new WipeNotificationAction()); case ACTION_REMOVE_NOTIFICATION: // remove the notification return new RemoveNotificationAction(); case ACTION_DEFER_1D: // defer the due date and remove notification if not pinned and due date is in the future return new Composite( new DeferDueAction(ONE_DAY), new Conditional( (context, data) -> !new TaskPin(data).value() && new EffectiveDueDate(data).value().addDuration(ONE_DAY).after(DateTime.nowAndHere()), new WipeNotificationAction())); case TaskContract.ACTION_BROADCAST_TASK_DUE: case TaskContract.ACTION_BROADCAST_TASK_STARTING: return new Composite( // post start and due notification on the due date channel new NotifyStickyAction(data -> CHANNEL_DUE_DATES, true), new UpdateWidgetsAction()); case ACTION_UNDO_COMPLETE: return new Composite( // cancel the delayed action new CancelDelayedAction(ACTION_FINISH_COMPLETE), // remove the undo notification new CancelNotificationAction("tasks.undo"), // repost notification new NotifyStickyAction( data -> new TaskPin(data).value() ? CHANNEL_PINNED : CHANNEL_DUE_DATES, false)); case ACTION_FINISH_COMPLETE: return new Composite( // cancel any delayed action, in case we're called before the timeout elapsed new CancelDelayedAction(ACTION_FINISH_COMPLETE), // unpin the task new PinAction(false), // finish the completion new CompleteAction(), // remove the undo notification new CancelNotificationAction("tasks.undo")); // TODO: trigger these for every notified task case Intent.ACTION_DATE_CHANGED: case Intent.ACTION_TIME_CHANGED: case Intent.ACTION_TIMEZONE_CHANGED: case ACTION_NEXT_DAY: case ACTION_RENOTIFY: // post pinned task on the pinned channel and other tasks on the due date channel return new NotifyStickyAction( data -> new TaskPin(data).value() ? CHANNEL_PINNED : CHANNEL_DUE_DATES, false); default: throw new RuntimeException(String.format("Unhandled action %s", action)); } }