Please see the code below. (working from my application)
public String getSkypeUsername(Context context, String name) { Cursor c = context.getContentResolver().query(ContactsContract.Data.CONTENT_URI, null, ContactsContract.Contacts.Data.MIMETYPE + "=?", new String[] { "vnd.android.cursor.item/com.skype.android.skypecall.action" }, null); while (c != null && c.moveToNext()) { String primary = c.getString(c.getColumnIndex(ContactsContract.Data.DISPLAY_NAME_PRIMARY)); String alternate = c.getString(c.getColumnIndex(ContactsContract.Data.DISPLAY_NAME_ALTERNATIVE)); if(primary.equalsIgnoreCase(name) || alternate.equalsIgnoreCase(name)) { String username = c.getString(c.getColumnIndex(ContactsContract.Data.DATA1)); c.close(); return username; } } c.close(); return null; }
All you have to do is call String username = getSkypeUsername (context, "name_of_person_to_call") . With this username makeSkypeCall is called (context, username)
public void makeSkypeCall(Context context, String username) { Intent sky = new Intent("android.intent.action.VIEW"); sky.setData(Uri.parse("skype:" + username + "?call")); context.startActivity(sky); }
Let me know if this helps!
Ishaan
source share