Created
June 28, 2013 08:17
-
-
Save brandhill/5883253 to your computer and use it in GitHub Desktop.
Android : Add a reminder/event in calendar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Build.VERSION.SDK_INT >= 14) { | |
Intent intent = new Intent(Intent.ACTION_INSERT) | |
.setData(Events.CONTENT_URI) | |
.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getTimeInMillis()) | |
.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis()) | |
.putExtra(Events.TITLE, "Yoga") | |
.putExtra(Events.DESCRIPTION, "Group class") | |
.putExtra(Events.EVENT_LOCATION, "The gym") | |
.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY) | |
.putExtra(Intent.EXTRA_EMAIL, "[email protected],[email protected]"); | |
startActivity(intent); | |
} | |
else { | |
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to check event already there please tell me