Вопрос

I'm working on an app that use Facebook SDK. I would like to give the user the possibility to call a Facebook Friends (shown in a listview) by clicking on their name.

There's a way to start a call intent whit the number of the selected friend? I mean, if I click on a friend who is called JESS is possible to search through the users's contacts to find out JESS's number?

(I'm not asking for getting phone number through the Facebook SDK, I've read is impossible)

Это было полезно?

Решение

solved whit a simple

public String getPhoneNumber(String name, Context context) {
    String ret = null;
    String selection = ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME
            + " like'%" + name + "%'";
    String[] projection = new String[] { ContactsContract.CommonDataKinds.Phone.NUMBER };
    Cursor c = context.getContentResolver().query(
            ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projection,
            selection, null, null);
    if (c.moveToFirst()) {
        ret = c.getString(0);
    }
    c.close();
    if (ret == null)
        ret = "Unsaved";
    return ret;
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top