相关疑难解决方法(0)

检索有关Google People API(Java)的联系人的信息

我使用从最近发布的谷歌的人API的例子在这里.我稍微扩展了一些示例,以显示有关联系人的其他信息,例如电子邮件地址和电话号码.应该完成这项工作的代码如下所示.

public class PeopleQuickstart {

    ...

    public static void getPersonInfo(Person person){

        // Get names
        List<Name> names = person.getNames();
        if(names != null && names.size() > 0) {
            for(Name personName: names) {
                System.out.println("Name: " + personName.getDisplayName());
            }
        }

        // Get email addresses
        List<EmailAddress> emails = person.getEmailAddresses();
        if(emails != null && emails.size() > 0) {
            for(EmailAddress personEmail: emails) {
                System.out.println("Email: " + personEmail.getValue());
            }
        }

        // Get phone numbers
        List<PhoneNumber> phones = person.getPhoneNumbers();
        if(phones != null && phones.size() > 0) { …
Run Code Online (Sandbox Code Playgroud)

java google-api google-contacts-api google-api-client

6
推荐指数
1
解决办法
5375
查看次数