开发者

How to add event to Google calendar in android?

hi i try to add a event to google calendar from my application.It adds the event to google calendar but it gives the UI "The application has stoped unexpectedly.Please try again."

code is here:

  myService.setUserCredentials(userName, userPassword); 
            Log.d("debug", "Login accepted ");
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
            sdf.setTim开发者_如何学PythoneZone(TimeZone.getTimeZone("UTC"));
            DateTime startTime = null;
            DateTime endTime=null;
            try {
                startTime = new DateTime(sdf.parse(DTSTART), TimeZone.getDefault());
                endTime = new DateTime(sdf.parse(DTEND), TimeZone.getDefault());
                Log.d("debug", "Time set Ok");
                }
            catch (ParseException e) {
                // TODO Auto-generated catch block
                Log.e("My Error", e.toString());
                e.printStackTrace();
                } 
            URL postUrl =
                  new URL("http://www.google.com/calendar/feeds/"+userName+"/private/full");
                CalendarEventEntry myEntry = new CalendarEventEntry();

                myEntry.setTitle(new PlainTextConstruct(SUMMARY));
                myEntry.setContent(new PlainTextConstruct(DESCRIPTION));                    
                When eventTimes = new When();
                eventTimes.setStartTime(startTime);
                eventTimes.setEndTime(endTime);                 
                myEntry.addTime(eventTimes);
                // Send the request and receive the response:
                CalendarEventEntry insertedEntry = myService.insert(postUrl, myEntry);

The LogCat response is:

07-17 12:04:04.518: ERROR/dalvikvm(760): Could not find method javax.xml.parsers.SAXParserFactory.getSchema, referenced from method com.google.gdata.util.common.xml.parsing.SecureGenericXMLFactory$SecureSAXParserFactory.getSchema
07-17 12:04:04.528: WARN/dalvikvm(760): VFY: unable to resolve virtual method 16278: Ljavax/xml/parsers/SAXParserFactory;.getSchema ()Ljavax/xml/validation/Schema;
07-17 12:04:04.528: WARN/dalvikvm(760): VFY:  rejecting opcode 0x6e at 0x0002
07-17 12:04:04.528: WARN/dalvikvm(760): VFY:  rejected Lcom/google/gdata/util/common/xml/parsing/SecureGenericXMLFactory$SecureSAXParserFactory;.getSchema ()Ljavax/xml/validation/Schema;
07-17 12:04:04.528: WARN/dalvikvm(760): Verifier rejected class Lcom/google/gdata/util/common/xml/parsing/SecureGenericXMLFactory$SecureSAXParserFactory;
07-17 12:04:04.528: WARN/dalvikvm(760): threadid=15: thread exiting with uncaught exception (group=0x4000fe70)
07-17 12:04:04.538: ERROR/AndroidRuntime(760): Uncaught handler: thread Thread-8 exiting due to uncaught exception
07-17 12:04:04.547: ERROR/AndroidRuntime(760): java.lang.VerifyError: com.google.gdata.util.common.xml.parsing.SecureGenericXMLFactory$SecureSAXParserFactory
07-17 12:04:04.547: ERROR/AndroidRuntime(760):     at com.google.gdata.util.common.xml.parsing.SecureGenericXMLFactory.getSAXParserFactory(SecureGenericXMLFactory.java:51)
07-17 12:04:04.547: ERROR/AndroidRuntime(760):     at com.google.gdata.util.XmlParser.getSAXParserFactory(XmlParser.java:90)
07-17 12:04:04.547: ERROR/AndroidRuntime(760):     at com.google.gdata.util.XmlParser.parse(XmlParser.java:679)
07-17 12:04:04.547: ERROR/AndroidRuntime(760):     at com.google.gdata.util.XmlParser.parse(XmlParser.java:576)
07-17 12:04:04.547: ERROR/AndroidRuntime(760):     at com.google.gdata.data.BaseEntry.parseAtom(BaseEntry.java:1015)
07-17 12:04:04.547: ERROR/AndroidRuntime(760):     at com.google.gdata.wireformats.input.AtomDataParser.parse(AtomDataParser.java:59)
07-17 12:04:04.547: ERROR/AndroidRuntime(760):     at com.google.gdata.wireformats.input.AtomDataParser.parse(AtomDataParser.java:39)
07-17 12:04:04.547: ERROR/AndroidRuntime(760):     at com.google.gdata.wireformats.input.CharacterParser.parse(CharacterParser.java:100)
07-17 12:04:04.547: ERROR/AndroidRuntime(760):     at com.google.gdata.wireformats.input.XmlInputParser.parse(XmlInputParser.java:52)
07-17 12:04:04.547: ERROR/AndroidRuntime(760):     at com.google.gdata.wireformats.input.AtomDualParser.parse(AtomDualParser.java:66)
07-17 12:04:04.547: ERROR/AndroidRuntime(760):     at com.google.gdata.wireformats.input.AtomDualParser.parse(AtomDualParser.java:34)
07-17 12:04:04.547: ERROR/AndroidRuntime(760):     at com.google.gdata.client.Service.parseResponseData(Service.java:2165)
07-17 12:04:04.547: ERROR/AndroidRuntime(760):     at com.google.gdata.client.Service.parseResponseData(Service.java:2098)
07-17 12:04:04.547: ERROR/AndroidRuntime(760):     at com.google.gdata.client.Service.insert(Service.java:1410)
07-17 12:04:04.547: ERROR/AndroidRuntime(760):     at com.google.gdata.client.GoogleService.insert(GoogleService.java:606)
07-17 12:04:04.547: ERROR/AndroidRuntime(760):     at com.mygoogle.GoogleCalendarActivity$GcalUpload.run(GoogleCalendarActivity.java:355)
07-17 12:04:04.547: ERROR/AndroidRuntime(760):     at java.lang.Thread.run(Thread.java:1058)

how to solve this ??


you can you use GoogleApiJavaClient see here why : http://code.google.com/p/gdata-java-client/wiki/MigratingToGoogleApiJavaClient

look here for more resource http://code.google.com/p/google-api-java-client/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜