我尝试从Android上的谷歌日历中读取,所以我按照instruction上的说明下载并安装谷歌客户端API 我使用教程网站上的示例代码。
try {
CalendarService myService = new CalendarService("demo-vibration-1");
myService.setUserCredentials(account, password);
// Send the request and print the response
URL feedUrl = new URL(
"https://www.google.com/calendar/feeds/default/owncalendars/full");
Log.v(TAG, "Calendar1");
CalendarFeed resultFeed = myService.getFeed(feedUrl,
CalendarFeed.class);
Log.v(TAG, "Calendar2");
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
CalendarEntry entry = resultFeed.getEntries().get(i);
Log.v(TAG, entry.getTitle().getPlainText());
}
} catch (Exception e) {[syntax="java"][/syntax]
e.printStackTrace();
}
它编译并运行但是抛出一个parserConfigurationException:org.xml.sax.SAXNotRecognizedException on
CalendarFeed resultFeed = myService.getFeed(feedUrl,
CalendarFeed.class);
它在android模拟设备上失败,但是如果我在常规java项目上运行代码就可以了。我将所有相关的gdata jar文件包含到我的项目构建路径中。 是否有人遇到同样的问题?
以下是异常跟踪 01-10 22:06:56.231:WARN / System.err(379):com.google.gdata.util.ParseException:org.xml.sax.SAXNotRecognizedException:http:/xml.org/sax/features/external-parameter -entities 01-10 22:06:56.241:WARN / System.err(379):at com.google.gdata.util.XmlParser.parse(XmlParser.java:708) 01-10 22:06:56.241:WARN / System.err(379):at com.google.gdata.util.XmlParser.parse(XmlParser.java:576) 01-10 22:06:56.241:WARN / System.err(379):at com.google.gdata.data.BaseFeed.parseAtom(BaseFeed.java:867) 01-10 22:06:56.241:WARN / System.err(379):at com.google.gdata.wireformats.input.AtomDataParser.parse(AtomDataParser.java:68) 01-10 22:06:56.251:WARN / System.err(379):at com.google.gdata.wireformats.input.AtomDataParser.parse(AtomDataParser.java:39) 01-10 22:06:56.251:WARN / System.err(379):at com.google.gdata.wireformats.input.CharacterParser.parse(CharacterParser.java:100) 01-10 22:06:56.251:WARN / System.err(379):at com.google.gdata.wireformats.input.XmlInputParser.parse(XmlInputParser.java:52) 01-10 22:06:56.251:WARN / System.err(379):at com.google.gdata.wireformats.input.AtomDualParser.parse(AtomDualParser.java:66) 01-10 22:06:56.251:WARN / System.err(379):at com.google.gdata.wireformats.input.AtomDualParser.parse(AtomDualParser.java:34) 01-10 22:06:56.261:WARN / System.err(379):at com.google.gdata.client.Service.parseResponseData(Service.java:2165) 01-10 22:06:56.261:WARN / System.err(379):at com.google.gdata.client.Service.parseResponseData(Service.java:2098) 01-10 22:06:56.261:WARN / System.err(379):at com.google.gdata.client.Service.getFeed(Service.java:1136) 01-10 22:06:56.261:WARN / System.err(379):at com.google.gdata.client.Service.getFeed(Service.java:998) 01-10 22:06:56.261:WARN / System.err(379):at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:638) 01-10 22:06:56.261:WARN / System.err(379):at com.google.gdata.client.Service.getFeed(Service.java:1017) 01-10 22:06:56.271:WARN / System.err(379):在eclipse.pratice.android.calendartest.calendartest.onCreate(calendartest.java:29) 01-10 22:06:56.271:WARN / System.err(379):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 01-10 22:06:56.271:WARN / System.err(379):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 01-10 22:06:56.271:WARN / System.err(379):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 01-10 22:06:56.271:WARN / System.err(379):在android.app.ActivityThread.access $ 2300(ActivityThread.java:125) 01-10 22:06:56.271:WARN / System.err(379):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:2033) 01-10 22:06:56.281:WARN / System.err(379):在android.os.Handler.dispatchMessage(Handler.java:99) 01-10 22:06:56.281:WARN / System.err(379):在android.os.Looper.loop(Looper.java:123) 01-10 22:06:56.281:WARN / System.err(379):在android.app.ActivityThread.main(ActivityThread.java:4627) 01-10 22:06:56.281:WARN / System.err(379):at java.lang.reflect.Method.invokeNative(Native Method) 01-10 22:06:56.291:WARN / System.err(379):at java.lang.reflect.Method.invoke(Method.java:521) 01-10 22:06:56.291:WARN / System.err(379):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:868) 01-10 22:06:56.291:WARN / System.err(379):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 01-10 22:06:56.291:WARN / System.err(379):at dalvik.system.NativeStart.main(Native Method) 01-10 22:06:56.291:WARN / System.err(379):引起:javax.xml.parsers.ParserConfigurationException:org.xml.sax.SAXNotRecognizedException:http:/xml.org/sax/features/external-参数实体