I am writing an application that should record events in a calendar in the background, without user input after installing the application. This means that the methods in which the event is generated using Intents is not what I want.
I found this code on a website, but it does not 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 anyone enters the "Google HIGHLY recommend you not to use this method" or the like, I already know that.
Has anyone got this job? I use Gingerbread on my device, so this can cause problems!
The only alternative I discovered is to use the GData APIs, but then I need to go through authentication, and therefore it is better ... there are applications that do not need authentication, so they should use this too! :)
If anyone can help please!
Thanks neil
source share