如何获得联系人与手机同步的社交媒体(谷歌,雅虎,...)相关联的,在android系统 [英] How to get contacts associated with social media(google,yahoo,...) synced with phone, in android

查看:143
本文介绍了如何获得联系人与手机同步的社交媒体(谷歌,雅虎,...)相关联的,在android系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,当我从手机获取联系人,它会得到所有的联系人(手机中,SIM卡,社会账户等)

My issue is, when I'm fetching contacts from phone, it will get all the contacts (from phone, SIM, social accounts etc)

我想知道,如果我能得到社会的帐户中的联系人分开?

i want to know, if I can get contacts from social accounts separately?

推荐答案

只要在应用程序的联系人同步,您可以查询 RawContacts (用 READ_CONTACTS 在清单许可),并让他们按帐户类型进行过滤。例如:

As long as the contacts for the applications are synced, you can query the RawContacts (with the READ_CONTACTS permission in your manifest) and get them filtered by account type. For example:

Cursor c = getContentResolver().query(
    RawContacts.CONTENT_URI,
    new String[] { RawContacts.CONTACT_ID, RawContacts.DISPLAY_NAME_PRIMARY },
    RawContacts.ACCOUNT_TYPE + "= ?",
    new String[] { <account type here> },
    null);

ArrayList<String> myContacts = new ArrayList<String>();
int contactNameColumn = c.getColumnIndex(RawContacts.DISPLAY_NAME_PRIMARY);
while (c.moveToNext())
{
    // You can also read RawContacts.CONTACT_ID to read the
    // ContactsContract.Contacts table or any of the other related ones.
    myContacts.add(c.getString(contactNameColumn));
}

这只是一个提供适当的帐户类型的问题。例如:

It's just a matter of supplying the appropriate account type. For example:


  • com.google针对Gmail,

  • com.whatsapp为WhatsApp的,

  • com.skype.contacts.sync为Skype,

  • &安培; C。

  • "com.google" for Gmail,
  • "com.whatsapp" for WhatsApp,
  • "com.skype.contacts.sync" for Skype,
  • &c.

这篇关于如何获得联系人与手机同步的社交媒体(谷歌,雅虎,...)相关联的,在android系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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