Android add event to calendar programmatically example

September 06, 2016 , 0 Comments

Hello friends,

Today i Just Give simple Example of Add event to calandar programatically. Its Add Event On System Calender which can we used for todo list.

Simple On method to add EVENT on android:
public void onAddEventClicked(View view) {
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType("vnd.android.cursor.item/event");

Calendar cal = Calendar.getInstance();
long startTime = cal.getTimeInMillis();
long endTime = cal.getTimeInMillis() + 60 * 60 * 1000;

intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startTime);
intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime);
intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true);

intent.putExtra(Events.TITLE, "Siddharth Birthday");
intent.putExtra(Events.DESCRIPTION, "This is a description");
intent.putExtra(Events.EVENT_LOCATION, "My Guest House");
intent.putExtra(Events.RRULE, "FREQ=YEARLY");

startActivity(intent);
}

 

 

 

 

Contributer

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google

0 comments:

Popular Posts