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