Newbie to using the Contacts Contract Content Provider.
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.
With Skype, your contacts are stored centrally on our servers. You can access them anywhere, as long as you sign in with the same account and password in Skype.
This is working for me:
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;
}
Pass in the contactID for usage:
String skypeID = getSkypeID(mContext, contactID);
if(!skypeID.matches("noMatch") {
//skypeID found
// Skype intent here
}
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With