@Override public Cursor runQueryOnBackgroundThread(CharSequence constraint) { String phone = ""; String cons = null; if (constraint != null) { cons = constraint.toString(); if (usefulAsDigits(cons)) { phone = PhoneNumberUtils.convertKeypadLettersToDigits(cons); if (phone.equals(cons)) { phone = ""; } else { phone = phone.trim(); } } } Uri uri = Phone.CONTENT_FILTER_URI.buildUpon() .appendPath(cons) .appendQueryParameter(DataUsageFeedback.USAGE_TYPE, DataUsageFeedback.USAGE_TYPE_SHORT_TEXT) .build(); /* * if we decide to filter based on phone types use a selection * like this. String selection = String.format("%s=%s OR %s=%s OR %s=%s", Phone.TYPE, Phone.TYPE_MOBILE, Phone.TYPE, Phone.TYPE_WORK_MOBILE, Phone.TYPE, Phone.TYPE_MMS); */ Cursor phoneCursor = mContentResolver.query(uri, PROJECTION_PHONE, null, //selection, null, null); if (phone.length() > 0) { Object[] result = new Object[7]; result[0] = Integer.valueOf(-1); // ID result[1] = Long.valueOf(-1); // CONTACT_ID result[2] = Integer.valueOf(Phone.TYPE_CUSTOM); // TYPE result[3] = phone; // NUMBER /* * The "\u00A0" keeps Phone.getDisplayLabel() from deciding * to display the default label ("Home") next to the transformation * of the letters into numbers. */ result[4] = "\u00A0"; // LABEL result[5] = cons; // NAME result[6] = phone; // NORMALIZED_NUMBER MatrixCursor translated = new MatrixCursor(PROJECTION_PHONE, 1); translated.addRow(result); return new MergeCursor(new Cursor[] { translated, phoneCursor }); } else { return phoneCursor; } }