Skip to content

Instantly share code, notes, and snippets.

@burakiren
Created May 6, 2016 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save burakiren/aa1316be642b79c1fb7ce29a11656f12 to your computer and use it in GitHub Desktop.
Save burakiren/aa1316be642b79c1fb7ce29a11656f12 to your computer and use it in GitHub Desktop.
Adding events to calendar
Calendar cal = Calendar.getInstance();
try {
cal.setTime(new SimpleDateFormat("dd-MMM-yyyy hh:mm:ss").parse("07052016"));
} catch (ParseException e) {
System.out.println("Parse Exception");
}
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime", cal.getTimeInMillis());
intent.putExtra("allDay", false);
intent.putExtra("rrule", "FREQ=YEARLY");
intent.putExtra("endTime", cal.getTimeInMillis() + 60 * 60 * 1000);
intent.putExtra("title", " Test Title");
startActivity(intent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment