在Android谷歌联系人API [英] Google contacts api on android

查看:144
本文介绍了在Android谷歌联系人API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在这几天和IM越来越糊涂。

我在报纸上看到Java客户端谷歌提供了在Android不会工作的地方很多,而事实并非如此。

可能有人点我在正确的方向?

 公共无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.main);


    ContactsService服务=新ContactsService(my_app_name);


    URL feedUrl = NULL;
    尝试 {
        feedUrl =新的URL(https://www.google.com/m8/feeds/contacts/default/full);
    }赶上(MalformedURLException异常E){
        e.printStackTrace();
    }

    尝试 {
        service.setUserCredentials(anAccount@gmail.com,thePassword);

        ContactFeed resultFeed =新ContactFeed();

        resultFeed =服务
                .getFeed(feedUrl,ContactFeed.class);
    }赶上(IOException异常E){
        e.printStackTrace();
    }赶上(ServiceException E){
        e.printStackTrace();
    }

}
 

和我得到的:

W / XmlParser的(793):javax.xml.parsers.ParserConfigurationException:org.xml.sax.SAXNotRecognizedException:http://xml.org/sax/features/external-parameter-entities

解决方案

目前,它在Android上工作的一个新的谷歌API的Java客户端库,这是在的 HTTP://$c$c.google.com/p/google-api-java-client/

我亲自用这个与谷歌文档列表API(但是,它并要求创建XML模型类按的 HTTP://$c$c.google.com/p/google-api-java-client/wiki/APIs#Google_Data_APIs )。

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("anAccount@gmail.com", "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

解决方案

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).

这篇关于在Android谷歌联系人API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆