开发者

adding reminder in calendar android

i tried the code but i am getting the error can anyone help

Calendar cal = Calendar.getInstance();
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event"); 
intent.putExtra("beginTime", cal.getTimeInMillis()); 
intent.putExtra("allDay", true); 
intent.putExtra("rrule", "FREQ=YEARLY"); 
intent.putExtra("endTime", cal.getTimeInMillis()+60*60*1000); 
intent.putExtra("title", "A Test Event from android app"); 
startActivity(intent);

i also added

<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />

in manifest fil开发者_如何学编程e.

ERROR:: ERROR/AndroidRuntime(702): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.EDIT typ=vnd.android.cursor.item/event (has extras) }


There error is when there is no activity to handle the action that is requested. By default the emulators do not have a calendar app installed on them. So there is nothing to handle this type of intent. It should work on a device that has a calendar event.

Also, make sure to have the calendar permissions set in the manifest. I missed that the first time around and was a little frustrated.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜