Question

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)

Was it helpful?

Solution

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;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top