Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get contacts from my Skype account in android?

Tags:

android

skype

I have implemented Skype video/audio calling functionality using Intent in my application it is working fine. But now I want to get all contacts list from Skype account is it possible?.

Is there any alternate way to show list of contacts of Skype account please give any idea?

like image 729
hharry_tech Avatar asked May 13 '14 13:05

hharry_tech


1 Answers

All contacts (provided they are synced) can be queried with the ContactsContract provider. The RawContacts.ACCOUNT_TYPE column of the RawContacts table indicates the account type for each entry ("raw" means that it contains all entries, e.g. multiple rows for a single person with multiple aggregated contacts).

To read the Skype contacts, you can do something like this:

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));
}

Be sure to also request the android.permission.READ_CONTACTS permission in the AndroidManifest.xml file.

like image 98
matiash Avatar answered Oct 08 '22 17:10

matiash