Get Skype name from Contacts list
Asked Answered
R

2

0

I'm getting skype contacts in my android device with this code:

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

    int contactNameColumn = c
            .getColumnIndex(RawContacts.DISPLAY_NAME_ALTERNATIVE);
    int count = c.getCount();
    skypeName = new String[count];
    for (int i = 0; i < count; i++) {
        c.moveToPosition(i);
        skypeName[i] = c.getString(contactNameColumn);

        Log.i("KEY", skypeName[i]);
    }
}

This code works fine, but it returns the skype display names.However is there any possibility to get Skype name not the display name so I can call or video call using that Skype name?. Thanks, Regards.

Refit answered 17/9, 2015 at 12:33 Comment(1)
@ChristopherSouvey Can you help me ?Refit
F
1

You need to query over the Data table not RawContacts, the Data table's data is organized by mimetypes, you just need to find the mimetype containing the info you're looking for, in skype's case it's: "vnd.android.cursor.item/com.skype.android.skypecall.action"

private void getContactList() {
    Cursor c = getContentResolver().query(
            Data.CONTENT_URI,
            new String[] { Data.CONTACT_ID, Data.DATA1 },
            Data.MIMETYPE + "= ?", 
            new String[] { "vnd.android.cursor.item/com.skype.android.skypecall.action" },
            null);

    while (c != null && c.moveToNext()) {
        String contact = c.getLong(0);
        String skype = c.getString(1);

        Log.i("contact " + contact + " has skype username: " + skype);
    }
}
  • I've typed the code here, so it's not checked and I might have typos
  • Make sure you ALWAYS close cursors via c.close()
Fluviatile answered 18/9, 2015 at 11:16 Comment(2)
Hello marmor again, I would like to get skype user photo, it is possible in the same way ?. Thanks @FluviatileRefit
Does the Skype Android SDK support allowing the SDP portion of the message to be modified, such that the media RTP streams will be routed to a different IP address and port than what the application is running on?Galatia
G
1

I'm not incredibly familiar with the Android-Skype API, but it looks like this line

.getColumnIndex(RawContacts.DISPLAY_NAME_ALTERNATIVE);

is what pulls the display name instead of the username. You could check the API and see if there's another RawContacts.method that fetches the username instead.

Additional information could be available here:

http://www.programmableweb.com/api/skype

or

http://www.skype.com/en/developer/

Griselgriselda answered 17/9, 2015 at 12:40 Comment(3)
Thank you for your response, but I tried the other methods, there isn't something related with username... And about the Skype API, I search I figure it out that no public API. And according to many link: https://mcmap.net/q/1372133/-android-api-for-skype-closed They don't have API for android.Refit
I suppose I misunderstood your original post. You are running this code through a terminal emulator on your android device?Griselgriselda
I'm running this from android device.Refit
F
1

You need to query over the Data table not RawContacts, the Data table's data is organized by mimetypes, you just need to find the mimetype containing the info you're looking for, in skype's case it's: "vnd.android.cursor.item/com.skype.android.skypecall.action"

private void getContactList() {
    Cursor c = getContentResolver().query(
            Data.CONTENT_URI,
            new String[] { Data.CONTACT_ID, Data.DATA1 },
            Data.MIMETYPE + "= ?", 
            new String[] { "vnd.android.cursor.item/com.skype.android.skypecall.action" },
            null);

    while (c != null && c.moveToNext()) {
        String contact = c.getLong(0);
        String skype = c.getString(1);

        Log.i("contact " + contact + " has skype username: " + skype);
    }
}
  • I've typed the code here, so it's not checked and I might have typos
  • Make sure you ALWAYS close cursors via c.close()
Fluviatile answered 18/9, 2015 at 11:16 Comment(2)
Hello marmor again, I would like to get skype user photo, it is possible in the same way ?. Thanks @FluviatileRefit
Does the Skype Android SDK support allowing the SDP portion of the message to be modified, such that the media RTP streams will be routed to a different IP address and port than what the application is running on?Galatia

© 2022 - 2024 — McMap. All rights reserved.