【问题标题】:Is it possible to get contacts from my Skype account in android?是否可以在 android 中从我的 Skype 帐户获取联系人?
【发布时间】:2014-05-13 13:16:01
【问题描述】:

我已经在我的应用程序中使用 Intent 实现了 Skype 视频/音频通话功能,它运行良好。但是现在我想从 Skype 帐户中获取所有联系人列表,这可能吗?

有没有其他方法可以显示 Skype 帐户的联系人列表,请提供任何想法?

【问题讨论】:

标签: android skype


【解决方案1】:

可以使用ContactsContract 提供程序查询所有联系人(前提是它们已同步)。 RawContacts 表的 RawContacts.ACCOUNT_TYPE 列指示每个条目的帐户类型(“原始”表示它包含所有条目,例如,具有多个聚合联系人的单个人的多行)。

要读取 Skype 联系人,您可以执行以下操作:

Cursor c = getContentResolver().query(
                RawContacts.CONTENT_URI,
                new String[] { RawContacts.CONTACT_ID, RawContacts.DISPLAY_NAME_PRIMARY },
                RawContacts.ACCOUNT_TYPE + "= ?",
                new String[] { "com.skype.contacts.sync" },
                null);

int contactNameColumn = c.getColumnIndex(RawContacts.DISPLAY_NAME_PRIMARY);
ArrayList<String> mySkypeContacts = new ArrayList<String>();

while (c.moveToNext())
{
    /// You can also read RawContacts.CONTACT_ID to query the 
    // ContactsContract.Contacts table or any of the other related ones.
    mySkypeContacts.add(c.getString(contactNameColumn));
}

请务必在AndroidManifest.xml 文件中请求android.permission.READ_CONTACTS 权限。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-27
    • 2017-02-07
    相关资源
    最近更新 更多