(原创)定时启动某个activity或者service的实现方式
2017-01-04 14:59
477 查看
Intent intent = new Intent("行为action"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setPackage(MoreServiceApplication.context.getPackageName()); PendingIntent sender = PendingIntent.getActivity(MoreServiceApplication.context, 0, intent, 0); AlarmManager alarm = (AlarmManager) MoreServiceApplication.context.getSystemService(ALARM_SERVICE); //alarm.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() +3 * 1000, sender); long firstTime = SystemClock.elapsedRealtime(); alarm.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime, 10 * 1000, sender);
相关文章推荐
- 每天一个linux命令(11):nl命令
- redis中的错误
- leetcode 477 Total Hamming Distance C++
- 文章标题
- 7.2
- ida动态调试笔记
- 创建view,保存GROUP_CONCAT数据
- 服务器不支持ipv6,怎么解决
- c++ 中几个常见的强制类型转换
- Lambda在Androidstudio上的配置
- Ascii编码
- mongodb 3.2 实战(三)整合Spring Data MongoDB
- c++ 操作Execl根据行号删除指定行
- 每天一个linux命令(10):cat 命令
- http协议详解
- easyui datebox 扩展清空按钮及日期判断
- PHP基础知识之————PHP Web脚本中使用FFmpeg
- 使用VisualVM检测
- Go语言中三种不同md5计算方式的性能比较
- 在Ubuntu系统上安装Nginx服务器的简单方法