Reputation: 788
I am creating a calendar event using startActivity by passing an intent. The calendar event gets created successfully and am also able to see all the information I pass except for the availability info. Whatever I send, the availability stays as Busy. Am I doing something wrong. My code is below.
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime", dtstart);
intent.putExtra("allDay", false);
intent.putExtra("endTime", dtend);
intent.putExtra("title", "blah blah");
intent.putExtra("description", "blah blah and more blah");
intent.putExtra("availability", 1);
ctx.startActivity(intent);
Upvotes: 1
Views: 393
Reputation: 788
In Android 4.0 or above the CalendarContract can be used as below which updates the availability also correctly....
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, "Test Title")
.putExtra(Events.DESCRIPTION, "Description")
.putExtra(Events.EVENT_LOCATION, "Location")
**.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY)**
.putExtra(Intent.EXTRA_EMAIL, "[email protected],[email protected]");
startActivity(intent);
Upvotes: 1