tags:

views:

59

answers:

1

Hi all. I use the following code in java. It works well and it adds events into Google calendar. But in android it gives the Exception “Error connecting with login URI”.Can anyone help me to solve this??

CalendarService myService = new CalendarService("calendarTest");
String userName = "[email protected]"; String userPassword = "xxxxxxx";

     // Create the necessary URL objects.
     try {
       metafeedUrl = new URL(METAFEED_URL_BASE + userName);
       eventFeedUrl = new URL(METAFEED_URL_BASE + userName
           + EVENT_FEED_URL_SUFFIX);
     } catch (MalformedURLException e) {
       // Bad URL
      strbuf.append(e.getMessage());
       System.err.println("Uh oh - you've got an invalid URL.");
       e.printStackTrace();
       return;
     }

     try 
     {          
       myService.setUserCredentials(userName, userPassword);
       // Demonstrate creating a single-occurrence event.
       CalendarEventEntry singleEvent = createSingleEvent(myService,"Event Title", "Event Description ");         
       System.out.println("Successfully created event " +singleEvent.getTitle().getPlainText() );

       // Demonstrate creating a quick add event.
       CalendarEventEntry quickAddEvent = createQuickAddEvent(myService,"Tennis with me June 22 3pm-3:30pm");           
       System.out.println("Successfully created quick add event "       + quickAddEvent.getTitle().getPlainText());          

     } 

catch.......

+1  A: 

This needs internet-access to add something to the calendar, right?

So you need to give your app the permission for internet access. Try adding this right before the closing tag of AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
pableu