Android Number matching bits Modification

Source: Internet
Author: User

In Android, the default number matching digits are 7 digits, that is, from the right to the left, if the two numbers have 7 digits that match, they are considered to be the same number, for example, "+ 86 1234567" and "01234567" are the same numbers. Therefore, "=" cannot be used to determine whether the two numbers match.

Android adds the phone_numbers_equal function in the SQLite layer for number matching judgment. This function is database-level and the corresponding SQL statement is phone_numbers_equal, android registers the function as two parameters and three parameters in the SQLite database. The two parameters are nothing more than number A and number B, the three parameters have an additional bool variable to indicate whether strict matching is used. This strict match is specifically used for Thailand. It seems that Thailand's number rules are special, but in our country, this variable is usually 0.

Go to the topic and modify the number of matching digits for Android. It is actually very simple. Modify oldphonenumberutils. the minimum number of matching digits in the CPP file is the expected number. This number is used in the phone_number_compare_loose function. This function is actually a real number matching function. The file location is: external \ SQLite \ android

Static IntMin_match = 7; // modify it to the number you want

There is also a Java function implementation in the framwork layer, compareloosely (a, B), framewoeks \ base \ telephony \ Java \ Android \ telephony \ phonenumberutils. java, where the min_match used also needs to be modified.

 

[note]: in the implementation of the phone_number_compare_loose and compareloosely functions on 2.1, a few fewer Code is a bug, it will affect matching of 6-digit numbers in English.

Related Article

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.