Android text message recipient automatic match is inconsistent with the display of user input

Source: Internet
Author: User

Android text message recipient automatic match is inconsistent with the display of user input
1. Save "12345678" as the contact person Test
2. enter the text message editing interface, enter "13712345678" in the recipient column, and then switch to the text input box to make the recipient's control defocus. The recipient is immediately displayed as "Test ", go back and click the recipient, and find that the target number is "12345678 ".
3. Send the message, prompting that the Message failed to be sent.
PS: the user originally wanted to send the text message to "13712345678". As a result, the system changed the number of the target sender because there was a "12345678" contact in the phone book, the message fails to be sent.

You can use the following methods to verify the number matching problems. If there are any exceptions, submit eService to mediatek.
Replace getRecipientEntryByPhoneNumber () in alps \ frameworks \ ex \ chips \ src \ com \ android \ ex \ chips \ RecipientAlternatesAdapter. java with the following 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 );
/// 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;
}
Note:


1.mm build frameworks/ex/chips first
2. Then mm build packages/app/Mms
Push the generated Mms to the mobile phone

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.