启动安卓中的定时功能
来源:互联网 发布:nodejs 搭配nginx 编辑:程序博客网 时间:2024/06/06 15:43
发布广播:
String userid = getUserId();String longitude = Position.getLongitude()+"";String latitude = Position.getLatitude()+"";if(userid != null && userid.length() != 0 && !longitude.equals("0.0") && !latitude.equals("0.0")){Map<String, String> params = new HashMap<String, String>(); params.put("uid", userid); params.put("longitude", longitude); params.put("latitude", latitude); try {send(params);} catch (MalformedURLException e) {// TODO 自动生成的 catch 块e.printStackTrace();}} manager = (AlarmManager) getSystemService(ALARM_SERVICE); int anHour = 15 * 1000; long triggerAtTime = SystemClock.elapsedRealtime() + anHour; String ALARM_ACTION = "auto_inquiry"; Intent i = new Intent(ALARM_ACTION); PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, 0); manager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtTime, pi);
广播接收者:
public void onReceive(Context context, Intent intent) {/*Log.i("ceshi", "2222");*/Intent i = new Intent(context, PositionService.class);context.startService(i);}注册组件:
<receiver android:name="io.dcloud.AlarmReceiver" android:permission="auto_inquiry"> <intent-filter> <action android:name="auto_inquiry" /> </intent-filter> </receiver>
0 0
- 启动安卓中的定时功能
- 安卓中的Spinner-不定时更新
- 安卓下载功能中的广播接收器
- 安卓中的反选功能
- 关于安卓项目中的技术选型-不定时更新
- 安卓定时
- 安卓 定时
- 安卓定时刷新界面
- 安卓开发,功能清单文件中的元素配置含义
- 安卓Volley库中的图片加载功能
- 安卓分享功能
- 安卓功能代码
- 安卓功能
- 安卓图标功能
- 启动/关闭数据库中的定时共享代理
- 安卓启动流程
- 安卓启动流程
- 安卓启动流程
- 【codeforces 766A】Mahmoud and Longest Uncommon Subsequence
- Ubuntu下局域网拷贝文件
- c# json
- Android Services之启动
- QQ18年,解密8亿月活的QQ后台服务接口隔离技术
- 启动安卓中的定时功能
- HDU4010 Query on The Trees LCT
- 3.不常关注的java点
- spring源码初步探索
- URAL1553 Caves and Tunnels
- React核心内容归纳总结
- struts2
- Redis五种数据类型介绍
- 广度优先搜索——01迷宫