项目:sms_DualCard
文件:RecipientsAdapter.java
@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_WORK_MOBILE,Phone.TYPE_MMS);
*/
Cursor phoneCursor =
mContentResolver.query(uri,PROJECTION_PHONE,null,//selection,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;
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。