Hi everyone, this is my first post here :)
I'm currently working on a feature for my Android app, that will let
users synchronize stuff to their Google Calendar. The problem is the
insert method keeps throwing an IOException and i don't know why (its
message says 'unknown error'). Here's the code i'm working with:
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("Tag-ToDo-List"));
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("Tag-ToDo-List");
try {
mCalendarService.setUserCredentials(userName, userPassword);
} catch (Exception e) {
// Invalid credentials
e.printStackTrace();
}
return true;
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Calendar Data API" 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/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---