简体   繁体   中英

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 file.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM