Android is a method to obtain a cell phone number based on APN
- 2020-06-23 01:57:20
- OfStack
This article illustrates Android's method of getting mobile phone number based on APN. Share to everybody for everybody reference. The details are as follows:
Before, many people said that it was impossible to get the phone number completely, because now you can't get it with a card, but you can get it with a card. Now we can think about the problem in another way, that is, APN. See the code:
APNNET. java as follows:
/**
* telecom APN The list of
* @author wudongdong
*
*/
public class APNNET {
public static String CTWAP="ctwap";
public static String CTNET="ctnet";
}
/**
* telecom APN The list of
* @author wudongdong
*
*/
public class APNNET {
public static String CTWAP="ctwap";
public static String CTNET="ctnet";
}
// To obtain APN The type of
/**
* To obtain APN type
* @author wudongdong
*
*/
public class ApnUtil {
private static Uri PREFERRED_APN_URI = Uri
.parse("content://telephony/carriers/preferapn");
/**
* get apntype
* @param context
* @return
*/
public static String getApnType(Context context){
String apntype="nomatch";
Cursor c = context.getContentResolver().query(PREFERRED_APN_URI,null, null, null, null);
c.moveToFirst();
String user=c.getString(c.getColumnIndex("user"));
if(user.startsWith(APNNET.CTNET)){
apntype=APNNET.CTNET;
}else if(user.startsWith(APNNET.CTWAP)){
apntype=APNNET.CTWAP;
}
return apntype;
}
}
/**
* To obtain APN type
* @author wudongdong
*
*/
public class ApnUtil {
private static Uri PREFERRED_APN_URI = Uri
.parse("content://telephony/carriers/preferapn");
/**
* get apntype
* @param context
* @return
*/
public static String getApnType(Context context){
String apntype="nomatch";
Cursor c = context.getContentResolver().query(PREFERRED_APN_URI,null, null, null, null);
c.moveToFirst();
String user=c.getString(c.getColumnIndex("user"));
if(user.startsWith(APNNET.CTNET)){
apntype=APNNET.CTNET;
}else if(user.startsWith(APNNET.CTWAP)){
apntype=APNNET.CTWAP;
}
return apntype;
}
}
Java code is as follows:
/**
If you have a cell phone number, you can send it IMSI Code to the specified interface, interface address is not convenient to say. But I can tell you 1 Yes, we have to go CTWAP And that's judgment APN The type of reason found many applications if APN Is the agent can not be connected, then introduce again 1 with APN Set the proxy information for the network.
*/
Cursor c = context.getContentResolver().query(PREFERRED_APN_URI,null, null, null, null);
c.moveToFirst();
String proxy=c.getString(c.getColumnIndex("proxy"));
if (!"".equals(proxy) && proxy!=null) {
Properties prop = System.getProperties();
System.getProperties().put("proxySet", "true");
prop.setProperty("http.proxyHost", c.getString(c.getColumnIndex("proxy")));
prop.setProperty("http.proxyPort", c.getString(c.getColumnIndex("port")));
String authentication = c.getString(c.getColumnIndex("user"))
+ ":" + c.getString(c.getColumnIndex("password"));
String encodedLogin = Base64.encode(authentication);
uc.setRequestProperty("Proxy-Authorization", " BASIC "
+ encodedLogin);
}
c.close();
I hope this article has been helpful for your Android programming.