This article illustrates the method of modifying number matching digits in Android programming. Share to everyone for your reference, specific as follows:
The default number matching digits on the Android2.1 is 7 digits, that is to say from right to left, if two numbers have 7 digits are matched, then consider the same number, such as +86 1234567 and 01234567 are the same number; So to determine if two numbers match, simply use "= =" It's not going to work.
Android added a function phone_numbers_equal to the SQLite layer to determine the number matching, which is database-level and the corresponding SQL statement is phone_numbers_equal, Android registers the function with 2 parameters and 3 parameters in the SQLite database, and the 2 parameters are no more than number A and number B, and 3 are a bool variable to indicate whether to use a strict match, which is specifically for Thailand, It seems that Thailand's number rules are very special, and in our country, this variable is generally 0.
To get to the point, to modify the number of Android numbers matching digits, in fact, is very simple, modify the OldPhoneNumberUtils.cpp file in the minimum number of matches is the number you want, the number in the function Phone_number_compare_loose function to use, This function is actually the real function of number matching, file location: external\sqlite\android
static int min_match = 7;
Change to the number you want
There is also a Java function implementation on the Framwork layer, compareloosely (a,b), framewoeks\base\telephony\java\android\telephony\ Phonenumberutils.java, the Min_match that is used also needs to be modified.
"Note": 2.1 Phone_number_compare_loose and compareloosely function of the implementation of a few code, is a bug it will affect the English state of the 6-bit length of the number matching
I hope this article will help you with the Android program.