Google contacts api on android

此生再无相见时 提交于 2019-11-28 09:06:53

问题


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

回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/8727531/google-contacts-api-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!