I'm writing an app that needs to write events to a calendar in the background, without input from the user once the app has been setup. This means that the methods where the event is created using Intents is not what I am after.
I found this code on a website, but it doesn't work:
long start = 1297512000; // 2011-02-12 12h00
long end = 1297515600; // 2011-02-12 13h00
String title = "TEST ENTRY - DELETE ME!!";
ContentValues cvEvent = new ContentValues();
cvEvent.put("calendar_id", 1);
cvEvent.put("title", title);
cvEvent.put("dtstart", start );
//cvEvent.put("hasAlarm", 1);
cvEvent.put("dtend", end);
getContentResolver().insert(Uri.parse("content://com.android.calendar/events"), cvEvent);
Now, before anybody wades in with the "Google HIGHLY recommend you don't use this method" or such like, I already know this.
Has anyone got this working? I'm running Gingerbread on my device, so that may cause an issue!
The only alternative I've found is to use the GData APIs, but then I need to authenticate which is why the above is better.... there are apps out there that need no authentication so they must be using this too! :)
If anyone can help, please do!
Thanks Neil