2016-12-08 3 views
0

私はAndroidが初めてです。現在、Googleの連絡先から連絡先リストと画像を取得できます。しかし、私のAppからの連絡先リストは、GoogleのGmailアプリのような私の会社の電子メールのための提案を提供していません。Androidは会社内で連絡先を検索してGmailのように提案します

これらの余分なメールアドレスを取得することは可能でしょうか?以下は

接触

public ArrayList<String> getNameEmailDetails() { 
    ArrayList<String> emlRecs = new ArrayList<String>(); 
    HashSet<String> emlRecsHS = new HashSet<String>(); 
    ContentResolver cr = getContentResolver(); 
    String[] PROJECTION = new String[] { ContactsContract.RawContacts._ID, 
      ContactsContract.Contacts.DISPLAY_NAME, 
      ContactsContract.Contacts.PHOTO_ID, 
      ContactsContract.CommonDataKinds.Email.DATA, 
      ContactsContract.CommonDataKinds.Photo.CONTACT_ID }; 
    String order = "CASE WHEN " 
      + ContactsContract.Contacts.DISPLAY_NAME 
      + " NOT LIKE '%@%' THEN 1 ELSE 2 END, " 
      + ContactsContract.Contacts.DISPLAY_NAME 
      + ", " 
      + ContactsContract.CommonDataKinds.Email.DATA 
      + " COLLATE NOCASE"; 
    String filter = ContactsContract.CommonDataKinds.Email.DATA + " NOT LIKE ''"; 
    Cursor cur = cr.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, PROJECTION, filter, null, order); 
    if (cur.moveToFirst()) { 
     do { 
      // names comes in hand sometimes 
      String name = cur.getString(1); 
      String email = cur.getString(3); 
      String contact_id = cur.getString(4); 
      Bitmap profilePic = openPhoto(Long.parseLong(contact_id)); 
      if (profilePic != null) { 
       profileList.add(new WordMatchAdapterWithIMG.profileWithIMG(email, profilePic)); 
      } 
     } while (cur.moveToNext()); 
    } 

    cur.close(); 
    return emlRecs; 
} 

答えて

0

を取得するためのコードは、私はあなたがGoogle Contacts APIを使用することをお勧めです。

GoogleコンタクトAPIを使用すると、クライアントアプリケーションは、ユーザーの連絡先を表示および更新できます。連絡先はユーザーのGoogleアカウントに保存されます。ほとんどのGoogleサービスは連絡先リストにアクセスできます。

連絡先のselfLinkのURLに許可GET要求送信、単一の接触を取得するには:成功した場合

https://www.google.com/m8/feeds/contacts/ {USEREMAIL} /フル/ {contactId}

を、サーバがで応答しますHTTP 200 OKステータスコードと要求された連絡先エントリ。

パブリック静的ContactEntry retrieveContact(ContactsService myServiceという){ ContactEntry接点= myService.getEntry(新しいURL( "https://www.google.com/m8/feeds/contacts/default/full/contactId")、 ContactEntry.class)。 //連絡先と何かをします。 リターン・コンタクト; }

有用な材料

関連する問題