日历事件和android中alarmManager服务 [英] calendar events and alarmManager service in android

查看:176
本文介绍了日历事件和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服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆