Android 上的 Google 通讯录 api
我已经这样做好几天了,我很困惑。
我在很多地方读到谷歌提供的java客户端“无法在android上工作”,但事实并非如此。
有人能指出我正确的方向吗?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ContactsService service = new ContactsService("my_app_name");
URL feedUrl = null;
try {
feedUrl = new URL("https://www.google.com/m8/feeds/contacts/default/full");
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
service.setUserCredentials("[email protected]", "thePassword");
ContactFeed resultFeed = new ContactFeed();
resultFeed = service
.getFeed(feedUrl, ContactFeed.class);
} catch (IOException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
}
}
我得到:
W/XmlParser(793): javax.xml.parsers.ParserConfigurationException: org.xml.sax.SAXNotRecognizedException: http://xml.org/sax/features/external-parameter-entities
I've been at this for days and im getting confused.
I've read in many places that the java client google provides "wont work on android", and it doesn't.
Could anybody point me in the right direction?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ContactsService service = new ContactsService("my_app_name");
URL feedUrl = null;
try {
feedUrl = new URL("https://www.google.com/m8/feeds/contacts/default/full");
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
service.setUserCredentials("[email protected]", "thePassword");
ContactFeed resultFeed = new ContactFeed();
resultFeed = service
.getFeed(feedUrl, ContactFeed.class);
} catch (IOException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
}
}
And i get:
W/XmlParser(793): javax.xml.parsers.ParserConfigurationException: org.xml.sax.SAXNotRecognizedException: http://xml.org/sax/features/external-parameter-entities
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有一个较新的 Google API Java 客户端库可以在 Android 上运行,它位于 http://code.google.com/p/google-api-java-client/。
我个人曾将其与 Google Documents List API 一起使用(但是,它确实需要按照 http://code.google.com/p/google-api-java-client/wiki/APIs#Google_Data_APIs)。
There is a newer Google APIs Java Client library that DOES work on Android, and it's at http://code.google.com/p/google-api-java-client/.
I have personally used this with the Google Documents List API (however, it did require creating XML model classes as per http://code.google.com/p/google-api-java-client/wiki/APIs#Google_Data_APIs).
如果您想要手机用户的联系人,为什么不尝试联系人内容提供商?
If you want the contacts of the user of the phone why not try the Contacts content provider?