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

衡水网站制作公司哪家专业建设集团排名

衡水网站制作公司哪家专业,建设集团排名,石家庄 网站建设 15369356722,网站建设费用核算闹钟的原理可用下面我自己画的一幅图来概括#xff1a;#xff08;不对的地方#xff0c;尽管吐槽#xff09; 我们来看看新建闹钟到闹钟响铃的步骤#xff1a; 1、新建一个闹钟#xff1a; ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22… 闹钟的原理可用下面我自己画的一幅图来概括不对的地方尽管吐槽     我们来看看新建闹钟到闹钟响铃的步骤    1、新建一个闹钟         ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 // 获得AlarmManager实例 final AlarmManager am (AlarmManager) getSystemService(ALARM_SERVICE); // 实例化Intent Intent intent new Intent(); // 设置Intent action属性 intent.setAction(com.test.BC_ACTION); intent.putExtra(msg, 该去开会啦); // 实例化PendingIntent final PendingIntent pi PendingIntent.getBroadcast(MainActivity.this, 0, intent, 0); // 获得系统时间 final long time System.currentTimeMillis(); am.set(AlarmManager.RTC_WAKEUP, time5000, sender);//5秒后闹铃 // 设置按钮单击事件 setBtn.setOnClickListener(new OnClickListener() { Override public void onClick(View v) { // 重复提示从当前时间开始间隔5秒 am.setRepeating(AlarmManager.RTC_WAKEUP, time, 5 * 1000, pi); } });       在AndroidMainfest.xml里注册广播接收器    ? 1 2 3 4 5 receiverandroid:nameMyReceiver intent-filter actionandroid:namecom.test.BC_ACTION/ /intent-filter /receiver          2、定义一个AlarmReceiver extends BroadcastReceiver接收广播并弹出闹钟提醒视图。      上面用到一个AlarmManage我们分别来看看它的处理闹钟流程和作用及例子。   处理闹钟流程对应AlarmManage有一个AlarmManagerServie服务程序该服务程序才是正真提供闹铃服务的它主要遍历闹铃列表并设置即将触发的闹铃给闹铃设备并且一直监听闹铃设备一旦有闹铃触发或者是闹铃事件发生AlarmManagerServie服务程序就会遍历闹铃列表找到相应的注册闹铃并发出广播。      作用及例子AlarmManage中文名闹钟或者叫做“全局定时器”更合适它的作用和Timer类似有两种使用方法1、在特定时长后特定时间执行某任务2、周期性的执行某任务AlarmManager对象配合Intent使用可以定时的开启一个Activity,发送一个BroadCast,或者开启一个Service.      1在指定时长后特定时间执行某项操作            ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 //操作发送一个广播广播接收后Toast提示定时操作完成 Intent intent newIntent(Main.this, alarmreceiver.class); intent.setAction(short); PendingIntent sender PendingIntent.getBroadcast(Main.this,0, intent,0); //设定一个五秒后的时间 Calendar calendarCalendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.add(Calendar.SECOND,5); AlarmManager alarm(AlarmManager)getSystemService(ALARM_SERVICE); alarm.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender); //或者以下面方式简化 //alarm.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()5*1000, sender); Toast.makeText(Main.this,五秒后alarm开启, Toast.LENGTH_LONG).show();        2周期性的执行某项操作 ? 1 2 3 4 5 6 7 8 9 10 11 12 Intent intent new Intent(Main.this, alarmreceiver.class); intent.setAction(repeating); PendingIntent senderPendingIntent .getBroadcast(Main.this, 0, intent, 0); //开始时间 long firstimeSystemClock.elapsedRealtime(); AlarmManager am(AlarmManager)getSystemService(ALARM_SERVICE); //5秒一个周期不停的发送广播 am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP , firstime, 5*1000, sender);        AlarmManager的取消其中需要注意的是取消的Intent必须与启动Intent保持绝对一致才能支持取消AlarmManager     ? 1 2 3 4 5 6 Intent intent newIntent(Main.this, alarmreceiver.class); intent.setAction(repeating); PendingIntent senderPendingIntent .getBroadcast(Main.this,0, intent,0); AlarmManager alarm(AlarmManager)getSystemService(ALARM_SERVICE); alarm.cancel(sender);     AlarmManager还将闹钟分为五种类型:   ? 1 public  staticfinalintELAPSED_REALTIME              //当系统进入睡眠状态时这种类型的闹铃不会唤醒系统。直到系统下次被唤醒才传递它该闹铃所用的时间是相对时间是从系统启动后开始计时的,包括睡眠       时间可以通过调用SystemClock.elapsedRealtime()获得。系统值是3 (0x00000003)。      ? 1 publicstaticfinalintELAPSED_REALTIME_WAKEUP  //能唤醒系统用法同ELAPSED_REALTIME系统值是2 (0x00000002) 。        ? 1 public static final int RTC    //当系统进入睡眠状态时这种类型的闹铃不会唤醒系统。直到系统下次被唤醒才传递它该闹铃所用的时间是绝对时间所用时间是UTC时间可以通过调用       System.currentTimeMillis()获得。系统值是1 (0x00000001) 。     ? 1 publicstaticfinalintRTC_WAKEUP  //能唤醒系统用法同RTC类型系统值为 0 (0x00000000) 。      ? 1 PublicstaticfinalintPOWER_OFF_WAKEUP    //能唤醒系统它是一种关机闹铃就是说设备在关机状态下也可以唤醒系统所以我们把它称之为关机闹铃。使用方法同RTC类型系统值为4 (0x00000004)。 综上所述感觉AlarmManage和NotificationManager差不多NotificationManager例子请见文章http://my.oschina.net/helu/blog/141728 转载于:https://www.cnblogs.com/Free-Thinker/p/6402361.html
http://www.pierceye.com/news/420104/

相关文章:

  • 网站设计命名规范广州短视频内容营销平台
  • 天津专门做网站的公司成都市城乡建设局网站
  • 品牌网站升级wordpress 4.9中文
  • 网站搭建软件广告标识标牌制作公司
  • 做造价在哪个网站查价格微信小程序是什么语言开发的
  • 网站建设平台接单做电子商务平台网站需要多少钱
  • 甘肃网站seo技术厂家企业简介内容
  • 视觉中国设计网站做音乐网站
  • 金坛区建设工程质量监督网站西宁百姓网免费发布信息
  • 运维 网站开发网站如何引入流量
  • 网站建设泉州效率网络西安网站设计公司哪家好
  • 青羊建站报价网上能注册公司吗怎么注册
  • 免费网站虚拟主机整站seo技术搜索引擎优化
  • 青岛网站建设订做油画风网站
  • 网站备案名称的影响吗六安哪里有做推广网站
  • 网站建设策划书网站发布与推广长沙公司网站费用
  • 设计网页英语口碑优化seo
  • 试客那个网站做的好北京做软件开发的公司
  • 网站多套系统如何调用网页大图素材
  • 沧州网站建设方案咨询wordpress需要 伪静态
  • 安徽省住房和城乡建设部网站郑州百姓网免费发布信息
  • 电子商务网站开发是指聊城市城乡建设部网站查询
  • 聊天室网站模板国内市场调研公司
  • 网站做不做备案有什么区别网站媒体给房开做内容推广
  • 昆明专业网站建设模板蚌埠app制作公司
  • 平面ui设计网站网页布局设计类型
  • 东莞企石网站建设网站怎么留住用户
  • 公司网站虚假宣传但网站不是我做的wordpress自豪地采用修改
  • 山西大同网站建设哪家好宜宾seo快速排名
  • 网站为什么做黄词骗流量网站图标在哪里修改