【问题标题】:Google contacts api on androidAndroid 上的 Google 联系人 API
【发布时间】:2012-01-04 13:16:52
【问题描述】:

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

我在很多地方都读到了 google 提供的 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

【问题讨论】:

  • @norbert 您对此有什么解决方案吗?你能分享我你的代码或链接吗?
  • 我已经解决了 GData api 的问题。看到这个帖子(noundla.blogspot.in/2014/01/…)

标签: java android google-contacts-api


【解决方案1】:

有一个更新的 Google APIs 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 创建 XML 模型类)。

【讨论】:

    【解决方案2】:

    如果您想要手机用户的联系人,何不试试Contacts content provider

    【讨论】:

    • 此链接现已失效。
    • 不恰当的答案。在回答之前仔细阅读问题。
    猜你喜欢
    • 2015-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-24
    • 2012-07-07
    • 1970-01-01
    相关资源
    最近更新 更多