Android is based on APN's approach to acquiring mobile numbers _android

Source: Internet
Author: User

This example describes Android's approach to acquiring mobile phone numbers based on APN. Share to everyone for your reference. Specifically as follows:

Before many people said that can not fully obtain mobile phone number, because there are now some cards can not be obtained, and some cards to obtain, now we can change a way of thinking to consider the problem, is to use the APN way. Please look at the code:

Apnnet.java is as follows:

/** * Telecom APN list * @author wudongdong * */public class Apnnet {public static String ctwap= "Ctwap"; 
public static String ctnet= "Ctnet"; 
/** * Telecom APN list * @author wudongdong * */public class Apnnet {public static String ctwap= "Ctwap"; 
public static String ctnet= "Ctnet"; }//Get APN type/** * Get 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= ' no 
Match "; 
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; /** * Get 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= ' no 
Match "; 
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;

 } 
}

The Java code is as follows:

/**
 access to mobile phone number can be transmitted IMSI code to specify the interface, interface address is not convenient to say. But can reveal a point, must go Ctwap, this is the reason to judge the type of APN, found that many applications if APN is to go agent words can not be networked, then introduce the APN set up the network agent information.
 */
  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 will help you with your Android program.

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.