Fix contact lookup from number (old + new)
This commit is contained in:
parent
491a71e017
commit
f4466f78fc
2 changed files with 9 additions and 0 deletions
|
@ -268,6 +268,10 @@ public class ContactPickerActivityNew extends AbstractContactPickerActivity {
|
||||||
|
|
||||||
// Finally using phone number
|
// Finally using phone number
|
||||||
String normalizedNumber = PhoneNumberUtils.getStrippedReversed(username);
|
String normalizedNumber = PhoneNumberUtils.getStrippedReversed(username);
|
||||||
|
if (TextUtils.isEmpty(normalizedNumber)) {
|
||||||
|
// non phone username
|
||||||
|
return null;
|
||||||
|
}
|
||||||
Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(username));
|
Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(username));
|
||||||
projection = new String[]{PhoneLookup._ID, PhoneLookup.NUMBER};
|
projection = new String[]{PhoneLookup._ID, PhoneLookup.NUMBER};
|
||||||
c = resolver.query(lookupUri, projection, null, null, null);
|
c = resolver.query(lookupUri, projection, null, null, null);
|
||||||
|
|
|
@ -29,6 +29,7 @@ import android.provider.Contacts;
|
||||||
import android.provider.Contacts.People;
|
import android.provider.Contacts.People;
|
||||||
import android.provider.Contacts.Photos;
|
import android.provider.Contacts.Photos;
|
||||||
import android.telephony.PhoneNumberUtils;
|
import android.telephony.PhoneNumberUtils;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class ContactPickerActivityOld extends Activity {
|
public class ContactPickerActivityOld extends Activity {
|
||||||
|
@ -120,6 +121,10 @@ public class ContactPickerActivityOld extends Activity {
|
||||||
|
|
||||||
public static Uri findUriPictureOfContact(ContentResolver resolver, String username, String domain) {
|
public static Uri findUriPictureOfContact(ContentResolver resolver, String username, String domain) {
|
||||||
String normalizedNumber = PhoneNumberUtils.getStrippedReversed(username);
|
String normalizedNumber = PhoneNumberUtils.getStrippedReversed(username);
|
||||||
|
if (TextUtils.isEmpty(normalizedNumber)) {
|
||||||
|
// non phone username
|
||||||
|
return null;
|
||||||
|
}
|
||||||
String[] projection = {Contacts.Phones.PERSON_ID};
|
String[] projection = {Contacts.Phones.PERSON_ID};
|
||||||
String selection = Contacts.Phones.NUMBER_KEY + "=" + normalizedNumber;
|
String selection = Contacts.Phones.NUMBER_KEY + "=" + normalizedNumber;
|
||||||
Cursor c = resolver.query(Contacts.Phones.CONTENT_URI, projection, selection, null, null);
|
Cursor c = resolver.query(Contacts.Phones.CONTENT_URI, projection, selection, null, null);
|
||||||
|
|
Loading…
Reference in a new issue