Fix the contacts' display name error
This commit is contained in:
parent
c82918db91
commit
718c272b33
1 changed files with 7 additions and 4 deletions
|
@ -113,6 +113,7 @@ public class ContactPickerActivityNew extends AbstractContactPickerActivity {
|
||||||
|
|
||||||
c.close();
|
c.close();
|
||||||
|
|
||||||
|
// Using the SIP contact field added in SDK 9
|
||||||
if (Version.sdkAboveOrEqual(Version.API09_GINGERBREAD_23)) {
|
if (Version.sdkAboveOrEqual(Version.API09_GINGERBREAD_23)) {
|
||||||
selection = ContactsContract.Data.CONTACT_ID + " = ? AND " + ContactsContract.Data.MIMETYPE + " = ?";
|
selection = ContactsContract.Data.CONTACT_ID + " = ? AND " + ContactsContract.Data.MIMETYPE + " = ?";
|
||||||
String projection[] = new String[] {ContactsContract.CommonDataKinds.SipAddress.SIP_ADDRESS};
|
String projection[] = new String[] {ContactsContract.CommonDataKinds.SipAddress.SIP_ADDRESS};
|
||||||
|
@ -147,8 +148,9 @@ public class ContactPickerActivityNew extends AbstractContactPickerActivity {
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
String id = intent.getData().getLastPathSegment();
|
String id = intent.getData().getLastPathSegment();
|
||||||
String contactName = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
|
String contactName = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
|
||||||
if (contactName == null)
|
if (contactName == null) {
|
||||||
contactName = retrieveContactName(id);
|
contactName = retrieveContactName(id);
|
||||||
|
}
|
||||||
choosePhoneNumberAndDial(contactName, id);
|
choosePhoneNumberAndDial(contactName, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,14 +160,15 @@ public class ContactPickerActivityNew extends AbstractContactPickerActivity {
|
||||||
|
|
||||||
|
|
||||||
private String retrieveContactName(String id) {
|
private String retrieveContactName(String id) {
|
||||||
Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
|
//Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
|
||||||
String selection = ContactsContract.CommonDataKinds.Phone._ID + " = ?";
|
Uri uri = ContactsContract.Contacts.CONTENT_URI;
|
||||||
|
String selection = ContactsContract.Contacts._ID + " = ?";
|
||||||
String[] selArgs = new String[] {id};
|
String[] selArgs = new String[] {id};
|
||||||
Cursor c = this.getContentResolver().query(uri, null, selection, selArgs, null);
|
Cursor c = this.getContentResolver().query(uri, null, selection, selArgs, null);
|
||||||
|
|
||||||
String name = "";
|
String name = "";
|
||||||
if (c.moveToFirst()) {
|
if (c.moveToFirst()) {
|
||||||
name = c.getString(c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
|
name = c.getString(c.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
|
||||||
}
|
}
|
||||||
c.close();
|
c.close();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue