Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

How to add a calendar event automatically w/o user action

I wan't to schedule calendar events with an alarm in android without the user having to press 'ok' or otherwise. Ideally this would all happen in the background when triggered by a listener event.

Code I am using right now

''' mSetCalendar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v){ Intent intent = new Intent(Intent.ACTION_INSERT); intent.setType("vnd.android.cursor.item/event"); intent.putExtra(CalendarContract.Events.TITLE, "Learn Android"); intent.putExtra(CalendarContract.Events.EVENT_LOCATION, "Home suit home"); intent.putExtra(CalendarContract.Events.DESCRIPTION, "Download Examples");''' // Setting dates GregorianCalendar calDate = new GregorianCalendar(2015, 10, 06); intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, calDate.getTimeInMillis()); intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, calDate.getTimeInMillis()); //Configuring Alarm intent.putExtra(CalendarContract.CalendarAlerts.HAS_ALARM, "hasAlarm"); // make it a full day event intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true); // make it a recurring Event intent.putExtra(CalendarContract.Events.RRULE, "FREQ=WEEKLY;COUNT=11;WKST=SU;BYDAY=TU,TH"); // Making it private and shown as busy intent.putExtra(CalendarContract.Events.ACCESS_LEVEL, CalendarContract.Events.ACCESS_PRIVATE); intent.putExtra(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_BUSY); startActivity(intent); } }); mLocationProvider = new LocationProvider(this, this); mLocationProvider.connect(); Log.d(TAG, "lati" + mCurrentLatitude); //Forcast.io API Setup Ends getForecast(); Log.d(TAG, "Main UI code is running!");. '''

While this add events to the without typing it still pops up a screen that the user has to agree with before it is added to the calander.

Thanks!! Any advice will be a huge help!