Summary of mobile phone system information, mobile phone system information

Source: Internet
Author: User

Summary of mobile phone system information, mobile phone system information


Get IMEI number:

/*** Get the IMEI number ** @ Description: * @ param activity * @ param @ return * @ return String */public static String getIMEI (Activity activity) {TelephonyManager manager = (TelephonyManager) activity. getSystemService (Context. TELEPHONY_SERVICE); return manager. getDeviceId ();}



Get IMSI:

/*** Get IMSI ** @ Description: * @ param activity * @ param @ return * @ return String */public static String getIMSI (Activity activity) {TelephonyManager manager = (TelephonyManager) activity. getSystemService (Context. TELEPHONY_SERVICE); return manager. getSubscriberId ();}



Mobile phone model:

/*** Mobile phone MODEL ** @ Description: * @ param @ return * @ return String */public static String getPhoneModel () {return android. OS. Build. MODEL ;}



System Version Number (numeric value ):
/*** System VERSION Number (numeric value) ** @ Description: * @ param @ return * @ return int */public static int getPhoneSdkVersionInt () {return Build. VERSION. SDK_INT ;}



System Version (string)

/*** System VERSION Number (String) ** @ Description: * @ param @ return * @ return String */public static String getPhoneSDKVersionChar () {return Build. VERSION. RELEASE ;}



APP version (string ):
/*** @ Description: APP version number (String) * @ param activity * @ param @ return * @ return String */public static String getAppVersionChars (Activity activity) {PackageManager packageManager = activity. getPackageManager (); PackageInfo packageInfo = null; try {packageInfo = packageManager. getPackageInfo (activity. getPackageName (), 0);} catch (NameNotFoundException e) {// TODO Auto-generated catch blocke. printStackTrace ();} return packageInfo. versionName ;}



APP version (integer ):

/*** APP version number (integer) ** @ Description: * @ param activity * @ param @ return * @ return int */public static int getAppVersionInt (Activity activity) {PackageManager packageManager = activity. getPackageManager (); PackageInfo packageInfo = null; try {packageInfo = packageManager. getPackageInfo (activity. getPackageName (), 0);} catch (NameNotFoundException e) {// TODO Auto-generated catch blocke. printStackTrace ();} return packageInfo. versionCode ;}


Obtain the Internet IP address (ip168 is unstable. You can obtain other IP addresses. The principle is similar ):

/*** Get Internet IP ** @ Description: * @ param @ return * @ return String */public static String GetNetIp () {URL infoUrl = null; InputStream inStream = null; string ipLine = ""; HttpURLConnection httpConnection = null; try {infoUrl = new URL ("http://ip168.com/"); URLConnection connection = infoUrl. openConnection (); httpConnection = (HttpURLConnection) connection; int responseCode = httpConnection. getResponseCode (); If (responseCode = HttpURLConnection. HTTP_ OK) {inStream = httpConnection. getInputStream (); BufferedReader reader = new BufferedReader (new InputStreamReader (inStream, "UTF-8"); StringBuilder strber = new StringBuilder (); String line = null; while (line = reader. readLine ())! = Null) strber. append (line + "\ n"); Pattern pattern = Pattern. compile ("((? :(?: 25 [0-5] | 2 [0-4] \ d | (1 \ d {2}) | ([1-9]? \ D) \.) {3 }(?: 25 [0-5] | 2 [0-4] \ d | (1 \ d {2}) | ([1-9]? \ D) "); Matcher matcher = pattern. matcher (strber. toString (); if (matcher. find () {ipLine = matcher. group () ;}} catch (MalformedURLException e) {e. printStackTrace ();} catch (IOException e) {e. printStackTrace ();} finally {try {if (inStream! = Null) {inStream. close ();} if (httpConnection! = Null) {httpConnection. disconnect () ;}} catch (IOException e) {e. printStackTrace () ;}} return ipLine ;}


Obtain the local IP Address:

/*** Obtain the local network IP ** @ Description: * @ param @ return * @ return String */public static String getLocalIpAddress () {try {Enumeration <NetworkInterface> en = NetworkInterface. getNetworkInterfaces (); while (en. hasMoreElements () {NetworkInterface ni = en. nextElement (); Enumeration <InetAddress> enIp = ni. getInetAddresses (); while (enIp. hasMoreElements () {InetAddress inet = enIp. nextElement (); if (! Inet. isLoopbackAddress () & (inet instanceof Inet4Address) {return inet. getHostAddress (). toString () ;}}} catch (SocketException e) {// TODO Auto-generated catch blocke. printStackTrace ();} return "0 ";}



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.