日历事件和android中alarmManager服务

编程入门 行业动态 更新时间:2024-10-09 17:27:25
本文介绍了日历事件和android中alarmManager服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图创建一个应用程序如下:

I'm trying to create an application as follows:

在用户插入事件的时间,并设置在这个时候做一些操作,如打开手机振动模式在这期间或关闭无线网络,所以我将让用户插入一行事件数据,我将其存储在Android的日历。

The user inserts an event time and sets some actions to be done in this time like turning the phone to vibration mode in this period or turning off the wifi, so I will let the user insert his event data, and I will store it on the android calendar.

然后保存在数据库中的操作。我需要的是一个触发,当日历事件发生,所以我可以赶上事件ID,并在我的数据库操作比较和执行的操作服务的用户的需求。

Then save the actions in database. What I need is a service that fires when a calendar event occurs so I can catch the event id and compare it with actions in my database and do the actions that the user needs.

任何帮助,请???

推荐答案

这广播接收我的手机上工作至少(没有测试等)。

This broadcast receiver works on my phone at least (have not tested others).

一个。在使用的manifest.xml接收

A. Using receiver in manifest.xml

<receiver android:name=".MyRemindersReceiver" > <intent-filter> <data android:scheme="content" /> <action android:name="android.intent.action.EVENT_REMINDER" /> </intent-filter> </receiver>

乙。在code。使用接收器

B. Using receiver in code

IntentFilter inFilter = new IntentFilter(CalendarContract.ACTION_EVENT_REMINDER); inFilter.addDataScheme("content"); registerReceiver(myRemindersReceiver, inFilter);

望着在调试这个广播消息,似乎这个消息有捆绑无需额外。然而,它具有(一个URI在intent.getData),我认为是开放的日历事件。所以,你需要查询这个URI来获取有关其余事件的详细信息。

Looking at this broadcast message in the debugger, it seems that this message has no extras in bundle. However it has a Uri in intent.getData(), which I assume to be the Uri for the calendar event. So you need to query this uri to get more information about the remainder event.

更多推荐

日历事件和android中alarmManager服务

本文发布于:2023-11-27 11:04:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637807.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日历   事件   alarmManager   android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!