Android 短信收件人自动匹配与用户输入的显示不一致
来源:互联网 发布:麒麟与ubuntu的区别 编辑:程序博客网 时间:2024/05/29 02:47
1.将号码“12345678”存为联系人Test后
2.进入短信编辑界面,在收件人一栏输入“13712345678”,再切换到文字输入框,使收件人那个控件失焦,可以看到收件人立即显示为“Test”,再返回去点击那个收件人,发现目标号码变成了“12345678”。
3.发送信息,提示发送失败。
PS:用户本来想要把短信发送到“13712345678”的,结果因为电话薄里面存了个“12345678”的联系人,系统就把发送目标的号码给变更了,导致信息发送失败。
号码匹配相关的问题都可以先用以下方式验证,如果还有异常,请提交eService到mediatek.
alps\frameworks\ex\chips\src\com\android\ex\chips\RecipientAlternatesAdapter.java中getRecipientEntryByPhoneNumber() 替换成下面的code:
public static RecipientEntry getRecipientEntryByPhoneNumber(Context context, String phoneNumber) {
Log.d(TAG, "[getRecipientEntryByPhoneNumber] phoneNumber: " + phoneNumber); /// M: MTK debug log
if (phoneNumber == null || TextUtils.isEmpty(phoneNumber)) {
return null;
}
final String[] PHONE_LOOKUP_PROJECTION = new String[] {
Phone._ID, // 0
Phone.CONTACT_ID, // 1
Phone.NUMBER, // 2
Phone.NORMALIZED_NUMBER, // 3
Phone.DISPLAY_NAME, // 4
};
long index = -1;
String currentNumber = "";
String normalizedNumber = PhoneNumberUtils.normalizeNumber(phoneNumber);
/// M: Query CONTACT_ID by giving phone number
Cursor cursorNormalize = context.getContentResolver().query(
Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, normalizedNumber), PHONE_LOOKUP_PROJECTION, null, null, null);
/// M: Return null if query result is empty
if (cursorNormalize == null) {
Log.d(TAG, "[getRecipientEntryByPhoneNumber] cursorNormalize is null"); /// M: MTK debug log
return null;
}
if (cursorNormalize.moveToFirst()) {
do {
index = cursorNormalize.getLong(1); /// M: Phone.CONTACT_ID
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "[getRecipientEntryByPhoneNumber] Query ID for " + phoneNumber
+ " RESULTS: "
+ " NAME : " + cursorNormalize.getString(4)
+ " CONTACT ID : " + cursorNormalize.getLong(1)
+ " ADDRESS :" + cursorNormalize.getString(2));
}
} while (cursorNormalize.moveToNext());
}
cursorNormalize.close();
/// M: No matched contact
if (index == -1) {
return null;
}
/// M: Query contact information by giving CONTACT_ID
RecipientEntry entry = null;
for (long i = index; i > 0; i--) {
Log.d(TAG, " getRecipientEntryByPhoneNumber i = "+ i);
Cursor cursor = context.getContentResolver().query(
Queries.PHONE.getContentUri(),
Queries.PHONE.getProjection(),
Queries.PHONE.getProjection()[Queries.Query.CONTACT_ID] + " IN (" + String.valueOf(i) + ")", null, null);
if (cursor.moveToFirst()) {
do {
if (cursor.getString(Queries.Query.DESTINATION).length() < currentNumber.length())
break;
if (true) {
Log.d(TAG, "[getRecipientEntryByPhoneNumber] Query detail for " + phoneNumber
+ " RESULTS: "
+ " NAME : " + cursor.getString(Queries.Query.NAME)
+ " CONTACT ID : " + cursor.getLong(Queries.Query.CONTACT_ID)
+ " ADDRESS :" + cursor.getString(Queries.Query.DESTINATION));
}
currentNumber = cursor.getString(1); /// M:Phone.NUMBER
if (PhoneNumberUtils.compare(PhoneNumberUtils.normalizeNumber(currentNumber), normalizedNumber)) {
entry = RecipientEntry.constructTopLevelEntry(
cursor.getString(Queries.Query.NAME),
cursor.getInt(Queries.Query.DISPLAY_NAME_SOURCE),
cursor.getString(Queries.Query.DESTINATION),
cursor.getInt(Queries.Query.DESTINATION_TYPE),
cursor.getString(Queries.Query.DESTINATION_LABEL),
cursor.getLong(Queries.Query.CONTACT_ID),
cursor.getLong(Queries.Query.DATA_ID),
cursor.getString(Queries.Query.PHOTO_THUMBNAIL_URI),
true, false);
break;
}
} while (cursor.moveToNext());
}
Log.d(TAG, "[getRecipientEntryByPhoneNumber] cursor count: " + (cursor != null ? cursor.getCount() : "null")); /// M: MTK debug log
cursor.close();
}
if (phoneNumber.length() - entry.getDestination().length() != 3 || entry.getDestination().length() < 11) {
Log.d(TAG, " the query do not meet the conditon, drop it");
entry = null;
}
return entry;
}
注意事项:
1. 先mm build frameworks/ex/chips
2. 然后 mm build packages/app/Mms
将生成的Mms push 到手机
2.进入短信编辑界面,在收件人一栏输入“13712345678”,再切换到文字输入框,使收件人那个控件失焦,可以看到收件人立即显示为“Test”,再返回去点击那个收件人,发现目标号码变成了“12345678”。
3.发送信息,提示发送失败。
PS:用户本来想要把短信发送到“13712345678”的,结果因为电话薄里面存了个“12345678”的联系人,系统就把发送目标的号码给变更了,导致信息发送失败。
号码匹配相关的问题都可以先用以下方式验证,如果还有异常,请提交eService到mediatek.
alps\frameworks\ex\chips\src\com\android\ex\chips\RecipientAlternatesAdapter.java中getRecipientEntryByPhoneNumber() 替换成下面的code:
public static RecipientEntry getRecipientEntryByPhoneNumber(Context context, String phoneNumber) {
Log.d(TAG, "[getRecipientEntryByPhoneNumber] phoneNumber: " + phoneNumber); /// M: MTK debug log
if (phoneNumber == null || TextUtils.isEmpty(phoneNumber)) {
return null;
}
final String[] PHONE_LOOKUP_PROJECTION = new String[] {
Phone._ID, // 0
Phone.CONTACT_ID, // 1
Phone.NUMBER, // 2
Phone.NORMALIZED_NUMBER, // 3
Phone.DISPLAY_NAME, // 4
};
long index = -1;
String currentNumber = "";
String normalizedNumber = PhoneNumberUtils.normalizeNumber(phoneNumber);
/// M: Query CONTACT_ID by giving phone number
Cursor cursorNormalize = context.getContentResolver().query(
Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, normalizedNumber), PHONE_LOOKUP_PROJECTION, null, null, null);
/// M: Return null if query result is empty
if (cursorNormalize == null) {
Log.d(TAG, "[getRecipientEntryByPhoneNumber] cursorNormalize is null"); /// M: MTK debug log
return null;
}
if (cursorNormalize.moveToFirst()) {
do {
index = cursorNormalize.getLong(1); /// M: Phone.CONTACT_ID
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "[getRecipientEntryByPhoneNumber] Query ID for " + phoneNumber
+ " RESULTS: "
+ " NAME : " + cursorNormalize.getString(4)
+ " CONTACT ID : " + cursorNormalize.getLong(1)
+ " ADDRESS :" + cursorNormalize.getString(2));
}
} while (cursorNormalize.moveToNext());
}
cursorNormalize.close();
/// M: No matched contact
if (index == -1) {
return null;
}
/// M: Query contact information by giving CONTACT_ID
RecipientEntry entry = null;
for (long i = index; i > 0; i--) {
Log.d(TAG, " getRecipientEntryByPhoneNumber i = "+ i);
Cursor cursor = context.getContentResolver().query(
Queries.PHONE.getContentUri(),
Queries.PHONE.getProjection(),
Queries.PHONE.getProjection()[Queries.Query.CONTACT_ID] + " IN (" + String.valueOf(i) + ")", null, null);
if (cursor.moveToFirst()) {
do {
if (cursor.getString(Queries.Query.DESTINATION).length() < currentNumber.length())
break;
if (true) {
Log.d(TAG, "[getRecipientEntryByPhoneNumber] Query detail for " + phoneNumber
+ " RESULTS: "
+ " NAME : " + cursor.getString(Queries.Query.NAME)
+ " CONTACT ID : " + cursor.getLong(Queries.Query.CONTACT_ID)
+ " ADDRESS :" + cursor.getString(Queries.Query.DESTINATION));
}
currentNumber = cursor.getString(1); /// M:Phone.NUMBER
if (PhoneNumberUtils.compare(PhoneNumberUtils.normalizeNumber(currentNumber), normalizedNumber)) {
entry = RecipientEntry.constructTopLevelEntry(
cursor.getString(Queries.Query.NAME),
cursor.getInt(Queries.Query.DISPLAY_NAME_SOURCE),
cursor.getString(Queries.Query.DESTINATION),
cursor.getInt(Queries.Query.DESTINATION_TYPE),
cursor.getString(Queries.Query.DESTINATION_LABEL),
cursor.getLong(Queries.Query.CONTACT_ID),
cursor.getLong(Queries.Query.DATA_ID),
cursor.getString(Queries.Query.PHOTO_THUMBNAIL_URI),
true, false);
break;
}
} while (cursor.moveToNext());
}
Log.d(TAG, "[getRecipientEntryByPhoneNumber] cursor count: " + (cursor != null ? cursor.getCount() : "null")); /// M: MTK debug log
cursor.close();
}
if (phoneNumber.length() - entry.getDestination().length() != 3 || entry.getDestination().length() < 11) {
Log.d(TAG, " the query do not meet the conditon, drop it");
entry = null;
}
return entry;
}
注意事项:
1. 先mm build frameworks/ex/chips
2. 然后 mm build packages/app/Mms
将生成的Mms push 到手机
0 0
- Android 短信收件人自动匹配与用户输入的显示不一致
- Android 控件之--发送邮件时的,收件人列表,可以自动匹配,可以删除,可以添加的。
- 调用发短信功能,收件人自动填充
- 让组合框自动匹配用户的输入
- DataGridViewCombobox用户输入后自动匹配
- 在信息收件人里输入号码,不要匹配到电话本里的服务号码
- 验证用户输入的口令是否与数据库中的匹配
- Android短信验证 自动输入到文本框
- android 拦截短信并自动输入
- Android开发---用户注册+短信验证+(自动获取短信信息)
- python自动发送邮件自定义邮件发件人和收件人的显示内容
- DataGridViewComboBoxColumn 可以让用户输入并自动匹配选项的问题
- android 输入框自动匹配-AutoCompleteTextView
- android第八节自动匹配输入内容
- Android之实现动态自动匹配输入
- Android短信发送流程之多收件人发送(原)
- Android短信发送流程之多收件人发送(原)
- 自动输入短信
- [libvirt]快速查找虚拟机对应的vnet设备
- Android KK上如何让三方APK发送的SMS不显示出来
- cocosStudio的使用-03-看不见界面,犯了一个小错误
- 共有继承 私有继承 保护继承 派生类的三种继承方式小结
- Hibernate格式化sql语句实体类 BasicFormatterImpl 源码
- Android 短信收件人自动匹配与用户输入的显示不一致
- Vim简明教程
- hdoj 1518 Square 【dfs】
- Permutations
- gcc 中参数-ftest-coverage -fprofile-arcs 使用
- Android SMS 从备份恢复后,会把手机原有信息删除掉
- iPhone文件读写系统操作
- 【note】stm32 keilMDK出现warning: function XX declared implicitly
- Console程序中取得窗口句柄