A summary of mobile phone system Information

Source: Internet
Author: User


Get IMEI number:

/** * Get IMEI number *  * @Description: * @param @param activity * @param @return * @return string */public static string Geti MEI (activity activity) {Telephonymanager manager = (Telephonymanager) activity.getsystemservice (context.telephony_ SERVICE); return Manager.getdeviceid ();}



Get IMSI:

/** * Get IMSI *  * @Description: * @param @param activity * @param @return * @return string */public static string Getim SI (activity activity) {Telephonymanager manager = (Telephonymanager) activity.getsystemservice (context.telephony_ SERVICE); return Manager.getsubscriberid ();}



Phone Model:

/** * Phone model *  * @Description: * @param @return * @return string */public static string Getphonemodel () {return Android. Os. Build.model;}



system Version (value):
/** * System Version (value) *  * @Description: * @param @return * @return int */public static int getphonesdkversionint () {return Bu Ild. VERSION. Sdk_int;}



system version (String)

/** * System Version (STRING) *  * @Description: * @param @return * @return string */public static string Getphonesdkversionchar () {R Eturn Build.VERSION.RELEASE;}



app Version (string):
/** * @Description: App version (string) * @param @param activity * @param @return * @return string */public static string getappvers Ionchars (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 (integral type) *  * @Description: * @param @param activity * @param @return * @return int */public static int Getappve Rsionint (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;}


Gets the extranet IP (ip168 is unstable. You can also use other URLs that can normally get to the IP. The principle is almost the same):

/** * Get Extranet IP * * @Description: * @param @return * @return string */public static string Getnetip () {URL Infourl = Null;in Putstream 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 (InS Tream! = null) {Instream.close ();} if (httpconnection! = null) {Httpconnection.disconnect ();}} catch (IOException e) {e.printstacktrace ();}} return ipline;}


get local network IP:

/** * Get local network IP *  * @Description: * @param @return * @return string */public static string getlocalipaddress () {try {Enum Eration<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";}


Demo Download: Https://github.com/xie2000/SystemInfoDemo


QQ Exchange Group:6399844

A summary of mobile phone system Information

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.