如何从Android的联系人列表中的Skype信息 [英] How to get skype info from the android contact list

查看:116
本文介绍了如何从Android的联系人列表中的Skype信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新手使用联系人合同内容提供商。

Newbie to using the Contacts Contract Content Provider.

我想从我的应用程序内拨打Skype电话时,我无法弄清楚如何获得从Android联系人Skype的信息。我通过ContentResolver的运行查询来获取所有的联系人的数据,但我不知道如何在数据中发现的Skype用户名。

I'm trying to make a skype call from within my application, and I can't figure out how to get the skype info from the android contacts. I am running a query through a ContentResolver to get all of the data for the contacts, but I don't know how to find the skype name within the data.

推荐答案

这是为我工作:

    public String getSkypeID(Context mContext, String contactID) {
    Log.i("getContactNumber");

    String returnID = "noMatch";

    ContentResolver cr = mContext.getContentResolver();
    Cursor skype = cr.query(ContactsContract.Data.CONTENT_URI, null, ContactsContract.Data.CONTACT_ID
            + " = " + contactID, null, null);

    while (skype.moveToNext()) {

        int type = skype
                .getInt(skype
                        .getColumnIndex(ContactsContract.CommonDataKinds.Im.PROTOCOL));
        String imName = skype.getString(skype
                .getColumnIndex(ContactsContract.CommonDataKinds.Im.DATA));

        switch (type) {
        case ContactsContract.CommonDataKinds.Im.PROTOCOL_SKYPE:
            Log.d("contactID: " + contactID + " type: " + type
                    + " imName: " + imName);

            returnID = imName;

            break;

        default:
            Log.v("Other numbers: " + imName);
            break;
        }

    }

    return returnID;
}

传中的ContactID的用法:

Pass in the contactID for usage:

    String skypeID = getSkypeID(mContext, contactID);

    if(!skypeID.matches("noMatch") {
    //skypeID found

    // Skype intent here

    }

希望有所帮助。

这篇关于如何从Android的联系人列表中的Skype信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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