Obtain the carrier type of the mobile phone by using the j2-based Technology
Author: Chen yuefeng
From: http://blog.csdn.net/mailbomb
In mobile phone software development, billing by using the sms sp has become very popular. For the SMS sp, in general, the channel number of the SMS (that is, the number activated by 106, china Mobile is different from China Unicom and China Telecom. That is to say, if the sms sp is used, the mobile phone belongs to different carriers, and different content needs to be sent to different channel numbers, in this way, the mobile phone software must deal with this problem during the deduction time.
There are two ways to solve this problem:
1,
The selection page appears, allowing you to select
This method is the simplest for program implementation, but it also has the biggest drawbacks in implementing functions. There are two main problems: a. The selection interface is not friendly each time. B. If the user chooses an error, the user cannot deduct the fee.
Therefore, this method is generally not used for processing.
2,
Determine by obtaining the SMS Service Center Number
If the mobile phone supports WMA, you can obtain the SMS service center number by obtaining the value of "wireless. messaging. SMS. SMSC. For the three carriers in China, China Mobile's SMS service center number is 13800xxx500, of which XXX is the region code of the number. China Unicom's SMS service center number is messy, however, they all start with 130, including 3G mobile phones. For China Telecom's mobile phones, after consulting customer service, they will all inform you that you do not need to set up the SMS service center number.
Based on the above content, the method code for determining the network of the mobile phone is as follows:
/**
* Obtain the mobile network type
*/
Private int
Getphonenetworktype (){
// Obtain the SMS center number
String SMSC =
System. getproperty ("wireless. messaging. SMS. SMSC ");
// Determine the category
If (SMSC! = NULL ){
// Mobile SMS center number
If (SMSC. startswith ("138 ")
| SMSC. startswith ("+ 138") | SMSC. startswith ("+ 86138 ")){
Return
Messagethread. china_mobile_type;
} Else
If (SMSC. startswith ("+ 86130") | SMSC. startswith ("0086130 ")
| SMSC. startswith ("130") | SMSC. startswith ("+ 130 ")){
Return messagethread. china_unicom_type;
}
}
// The default value is China Telecom mobile phone
Return messagethread. china_telecom_type;
}
Others determine the network to which the mobile phone belongs by obtaining the mobile phone number. Because the mobile phone number is not supported by the general technology of the mobile phone number, it is necessary to know the information of the mobile phone number segment, rather than very practical.
If you have any good comments and suggestions, you can send me an email to exchange: cqucyf@gmail.com.