简体   繁体   中英

Android Adding an Event to calendar

I want to put a button in my android application. When user taps the button it should open a default popup screen where we can enter starttime , endtime etc to save an event to personal calendar.

I am new to android development so I am unable open that popup screen in my application can any one help me out in doing this.

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);

The extra parameters are optional of course, they will just fill in some initial values on the form. You can chose to add them or remove them yourself.

Also I'm not sure but I think you need permission:

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

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