2013-09-22 3 views
3

내 Android 앱용 Google 연락처 API를 구현해야합니다. 하지만 지금까지 안드로이드에 대한 참조를 찾지 못했습니다. 나는 자바에 대해 하나의 발견 : https://developers.google.com/google-apps/contacts/v3/Google 연락처 api for android

하지만이 코드를 사용할 때 :

ContactsService myService = new ContactsService("<var>YOUR_APPLICATION_NAME</var>"); 

을 나는 "있는 ExceptionInInitializerError"라는 런타임 오류가 발생합니다.

나는 이미 herehere을 보았지만 "ContactsService"개체를 어떻게 초기화 할 수 있는지에 대한 구체적인 해결책을 얻지 못했습니다.

여러분 중 친절하게도 내 앱에서 Google 연락처 API를 구현할 수있는 가이드 라인을 제공 할 수 있습니까?

+0

이에 대한 모든 솔루션을 거지에게 도움이 될 수 있습니다이 코드를 시도하세요? – Noundla

답변

0

당신

public void printAllContacts()throws ServiceException, IOException { 

    ContactsService myService = null; 
    myService = new ContactsService(accessToken);//add here your access token 
    myService.setAuthSubToken(accessToken);//add here your access token 
    URL feedUrl = new URL("https://www.google.com/m8/feeds/contacts/default/full?max-results=5000"); 
    ContactFeed resultFeed = myService.getFeed(feedUrl, ContactFeed.class); 
    for (int i = 0; i < resultFeed.getEntries().size(); i++) { 
     ContactEntry entry = resultFeed.getEntries().get(i); 
     if (entry.hasName()) { 
      Name name = entry.getName(); 
      if (name.hasFullName()) { 
       String fullNameToDisplay = name.getFullName().getValue(); 
       if (name.getFullName().hasYomi()) { 
        fullNameToDisplay += "(" 
          + name.getFullName().getYomi() + ")"; 
       } 
       System.out.println(fullNameToDisplay); 
      } 
      for (Email email : entry.getEmailAddresses()) { 

       System.out.println(email.getAddress()); 
      } 
      Link photoLink = entry.getContactPhotoLink(); 
      String photoLinkHref = photoLink.getHref(); 
      System.out.println("Photo Link:" + photoLinkHref+"\n"); 
     } 
    } 
}