我创建了一个广播接收器来挂钩日历 EVENT_REMINDER 并获取有关事件的信息
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bReceiver = new HealtDroidBroadcastReceiver();
IntentFilter inf = new IntentFilter("android.intent.action.EVENT_REMINDER");
inf.addDataScheme("content");
inf.addDataAuthority("com.android.calendar",null);
registerReceiver(bReceiver,inf);
}
在广播接收器类中:
public void onReceive(Context context, Intent intent) {
Uri uri = intent.getData();
String intentAction = intent.getAction();
ContentResolver cr = context.getContentResolver();
String sUri = uri.toString();
Uri alertUri = Uri.parse(sUri);
Cursor alertCursor = cr.query(alertUri, ALERT_PROJECTION,
null /* selection */, null, null /* sort order */);
但是当 cr.query 时出现错误:
未知 URL 内容://com.android.calendar/1373401980000