当前位置: 首页 > news >正文

公司内部网站建设管理办法重庆建设汽车系统股份有限公司

公司内部网站建设管理办法,重庆建设汽车系统股份有限公司,正保建设工程教育网站,黄石网站建设教程官网镇楼#xff1a;设置重复闹铃时间 闹钟具有以下特征#xff1a; 它们可让您按设定的时间和/或间隔触发 intent。您可以将它们与广播接收器结合使用#xff0c;以启动服务以及执行其他操作。它们在应用外部运行#xff0c;因此即使应用未运行#xff0c;或设备本身处…官网镇楼设置重复闹铃时间 闹钟具有以下特征 它们可让您按设定的时间和/或间隔触发 intent。您可以将它们与广播接收器结合使用以启动服务以及执行其他操作。它们在应用外部运行因此即使应用未运行或设备本身处于休眠状态您也可以使用它们来触发事件或操作。它们可以帮助您最大限度地降低应用的资源要求。您可以安排定期执行操作而无需依赖定时器或持续运行后台服务 简单来说要在设定的时间执行具体的任务可以用 AlarmManager 来实现。 注这里说的应用通过 AlarmManager 设置的闹钟 和 系统闹钟应用里设置的闹钟 不一样不要混淆了。 举个例子 应用通过 AlarmManager 设置闹钟到某个时间点获取版本更新信息简称 A 。 系统闹钟应用里设置的每天早上8点的起床闹钟简称 B 。 添加 A 时不会添加到系统闹钟应用里触发 A 时 只会触发应用里的事件如 Receiver不会有系统闹钟的声音、震动、UI 弹窗等东西。 触发 B 时有系统闹钟的声音、震动、UI 弹窗等东西。 初始化 AlarmManager alarmManager (AlarmManager) getSystemService(ALARM_SERVICE);设置单次闹钟 set 30s 后唤醒设备并触发闹钟 模拟器测试 设置闹钟后不退出应用锁屏到时间可以触发不会唤醒屏幕设置闹钟后退出应用并清理进程到时间可以触发设置闹钟后退出应用并清理进程锁屏到时间可以触发不会唤醒屏幕 使用 PendingIntent 来实现到时间后会触发 AlarmReceiver.onReceive() Intent intent new Intent(mContext, AlarmReceiver.class); pendingIntent1 PendingIntent.getBroadcast(mContext, 0, intent, 0);alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,SystemClock.elapsedRealtime() 30 * 1000,pendingIntent1);setExact setExact 和 set 用法是一样的差别是 setExact 比 set 时间更精确。大白话setExact 是 30 秒后触发set 可能 30秒后触发也可能 35 秒后触发。 30s 后唤醒设备并触发闹钟 Intent intent new Intent(mContext, ExactAlarmReceiver.class); pendingIntent6 PendingIntent.getBroadcast(mContext, 6, intent, 0);alarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP,SystemClock.elapsedRealtime() 30 * 1000,pendingIntent6);设置重复闹钟 设置重复闹钟用 setInexactRepeating 和 setRepeating 。 setInexactRepeating 必须使用指定的时间间隔常量此方法会同步多个不精确的重复闹钟并同时触发它们。这样可以减少耗电量。setRepeating 精确闹钟可以自定义时间间隔。 setInexactRepeating 使用 PendingIntent 和 Calendar 来实现到时间后会触发 AlarmReceiver.onReceive() 在上午 10:10 左右唤醒设备并触发闹钟 Calendar calendar Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(Calendar.HOUR_OF_DAY, 10); calendar.set(Calendar.MINUTE, 10);Intent intent new Intent(mContext, AlarmReceiver.class); pendingIntent3 PendingIntent.getBroadcast(mContext, 0, intent, 0);// With setInexactRepeating(), you have to use one of the AlarmManager interval // constants--in this case, AlarmManager.INTERVAL_DAY. alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),AlarmManager.INTERVAL_FIFTEEN_MINUTES, pendingIntent3);指定的时间间隔有 15 分钟、半小时、一小时、半天、一天分别对应 INTERVAL_FIFTEEN_MINUTESINTERVAL_HALF_HOURINTERVAL_HOURINTERVAL_HALF_DAYINTERVAL_DAY setRepeating 使用 PendingIntent 和 Calendar 来实现到时间后会触发 AlarmReceiver.onReceive() 在上午 9:25 准时唤醒设备并触发闹钟此后每 1 分钟触发一次 Intent intent new Intent(mContext, AlarmReceiver.class); pendingIntent4 PendingIntent.getBroadcast(mContext, 0, intent, 0);// Set the alarm to start at 9:25 a.m. Calendar calendar Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(Calendar.HOUR_OF_DAY, 9); calendar.set(Calendar.MINUTE, 25);// setRepeating() lets you specify a precise custom interval--in this case, // 1 minutes. alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),1000 * 60 * 1, pendingIntent4);取消闹钟 使用 cancel() 方法传入不想触发的 PendingIntent 即可。 if (alarmManager ! null) {if (null ! pendingIntent1) {alarmManager.cancel(pendingIntent1);}if (null ! pendingIntent2) {alarmManager.cancel(pendingIntent2);}if (null ! pendingIntent3) {alarmManager.cancel(pendingIntent3);}}获取系统闹钟应用里设置的闹钟 获取系统闹钟应用里设置的闹钟获取最临近的一个返回一个 AlarmClockInfo AlarmManager alarmManager (AlarmManager) getSystemService(ALARM_SERVICE); AlarmManager.AlarmClockInfo info alarmManager.getNextAlarmClock();AlarmClockInfo.getTriggerTime() 方法返回的是 UTC 时间转为日期形式更直观 /** * 1692453600000 Sat, 2023 08 19 22:00:00 GMT * */ private String utc2Date(long utcTime){Calendar calendar Calendar.getInstance();calendar.setTimeInMillis(utcTime);SimpleDateFormat sdfGmt new SimpleDateFormat(EEE, yyyy MM d HH:mm:ss GMT, Locale.getDefault());//星期三, 2023 08 16 22:00:00 GMTsdfGmt.setTimeZone(TimeZone.getDefault());return sdfGmt.format(calendar.getTime());}
http://www.huolong8.cn/news/81314/

相关文章:

  • 新网站怎么快速收录必做重庆市建设工程造价信息2020
  • 福鼎整站优化百度图片识别在线识图
  • 如何自己开发软件appseo引擎优化外包
  • 网站改版后 搜索不到WordPress制作小说网站
  • 网站做数据监测中国建设网站用户名
  • wordpress做下载型网站北京海华城市建设学校网站
  • 广州天河 网站建设发布网站后不可能存在的文件夹是
  • 交互动效库 网站服装设计学校排名国内
  • 微信微网站制作公司外贸网站开发开发
  • 论文 网站建设电子商务网站后台功能
  • 网站流程做网站的公司有
  • 重庆网站制作招聘wordpress 新浪微博分享
  • 网站改版建设原则怎么做关于梦想的网站免费的
  • python网站开发 pdf四川最新情况最新消息今天
  • 怎么样从头开始做网站教育培训机构有哪些
  • 网站建设菜单栏设计成立公司注意事项
  • 万网续费登录网站湖南网站建设哪里好
  • 如何防止网站被盗免费发布信息大全
  • 北京产品网站设计哪家专业网站后台放在哪里
  • 网站规划名词解释营销型网站服务
  • 自己做的网站在浏览器上显示不安全国内外网站建设2017
  • 百度网站制作推广湖南又出现5例
  • 承德专业做网站沈阳互联网公司
  • html5 中文网站模板wordpress二维码活码
  • 济南网站建设加q479185700mukioplayerwp wordpress
  • 永久免费手机网站自助建站wordpress同行者画廊
  • 网站百度搜索不到为什么要做seo
  • 宁波网站建设制作推广广东网
  • 益阳网站制作公司免费psd模板素材
  • 湛江网站建站建设公司网址怎么注册