Android 上的 Google 通讯录 api

发布于 2024-12-24 22:37:35 字数 1175 浏览 6 评论 0原文

我已经这样做好几天了,我很困惑。

我在很多地方读到谷歌提供的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

稍尽春風 2024-12-31 22:37:35

有一个较新的 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).

懒的傷心 2024-12-31 22:37:35

如果您想要手机用户的联系人,为什么不尝试联系人内容提供商

If you want the contacts of the user of the phone why not try the Contacts content provider?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文