gpt4 book ai didi

java - Android 上的 Google 联系人 API

转载 作者:太空狗 更新时间:2023-10-29 12:54:08 25 4
gpt4 key购买 nike

我已经在这个问题上好几天了,我感到很困惑。

我在很多地方都读到,谷歌提供的 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("anAccount@gmail.com", "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

最佳答案

有一个更新的 Google APIs Java 客户端库可以在 Android 上运行,它位于 http://code.google.com/p/google-api-java-client/。 .

我亲自将其与 Google 文档列表 API 一起使用(但是,它确实需要根据 http://code.google.com/p/google-api-java-client/wiki/APIs#Google_Data_APIs 创建 XML 模型类)。

关于java - Android 上的 Google 联系人 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8727531/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com