• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Create an event in calendar (ICS and higher) without user interaction

daweefolk

Lurker
I'm making an app that, among other things, lets users add events to their phone's calendar to "track seizures". Here's the code I have to create the event:
Code:
Intent calIntent = new Intent(Intent.ACTION_INSERT);
calIntent.setType("vnd.android.cursor.item/event");   
calIntent.putExtra(Events.TITLE, "Tracked seizure");
calIntent.putExtra(Events.DESCRIPTION, value);
Calendar c=Calendar.getInstance();
GregorianCalendar calDate = new GregorianCalendar(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH));
calIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,
c.get(Calendar.HOUR));
calIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
c.get(Calendar.HOUR));
startActivity(calIntent);
What I want is when they push the button an AlertDialog pops up (and it does), containing an EditText to let the user give the description. When they click "OK" in the AlertDialog, I want the event to be created right then. Instead, it just brings up the screen you'd get if you went to the calendar app and went to add an event. Can I skip that screen altogether?

Sorry if this is confusing, ask if anything needs clarifying. Thanks!
 
Back
Top Bottom