Hi, this is an issue for me too. I tried with the general (Java)
Calendar API, and i managed to log in but the 'insert' method always
throws an IOException (its message says 'unknown error'). Below is the
code i am using:
private static CalendarService mCalendarService;
private static URL mAllCalendarsFeedUrl=null;
private static final String ALLCALENDARS_FEED_URL_SUFFIX =
"/private/full";
private static final String METAFEED_URL_BASE =
"http://www.google.com/calendar/feeds/";
public final static boolean createEvent(String title) {
authenticate(*,*);
CalendarEventEntry myEntry = new
CalendarEventEntry();
myEntry.setTitle(new PlainTextConstruct
(title));
myEntry.setContent(new PlainTextConstruct
("Content"));
DateTime startTime = new DateTime(new Date());
When eventTimes = new When();
eventTimes.setStartTime(startTime);
myEntry.addTime(eventTimes);
// Send the request and receive the response:
try {
CalendarEventEntry insertedEntry =
mCalendarService.insert
(mAllCalendarsFeedUrl, myEntry);
} catch (IOException e) { // it throws this
exception every time,
dunno what i'm doing wrong
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
public final static boolean authenticate(String userName,
String
userPassword){
// Create necessary URL objects
try {
mAllCalendarsFeedUrl = new URL(METAFEED_URL_BASE +
userName +
ALLCALENDARS_FEED_URL_SUFFIX);
} catch (MalformedURLException e) {
// Bad URL
System.err.println("Uh oh - you've got an invalid
URL.");
e.printStackTrace();
return false;
}
// Create CalendarService and authenticate using
ClientLogin
mCalendarService = new CalendarService("MyApp");
try {
mCalendarService.setUserCredentials(userName,
userPassword);
} catch (Exception e) {
// Invalid credentials
e.printStackTrace();
}
return true;
}
If anyone managed event insertion with Google Calendar on Android
please help us :)
Thanks,
Teo
On Jan 27, 10:51 pm, Markus Junginger <[email protected]> wrote:
> I would like to insert a new event (start time, end time, and event
> name) in the user'scalendar. How can I do that? I have the
> impression, that the SDK does not have the API for it (yet), but the
> G1 has the APIs. Would the CalendarProvider class the way to go?
>
> See also:http://code.google.com/p/android/issues/detail?id=1389
> Did anyone succeed in adding an event to thecalendar?
>
> Thanks!
> Markus
> --http://jars.de
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---