Recently in the development, need to use some system information, here I write these methods into a tool class to facilitate later reuse, the tool class has the following 6 functions:
1, access to mobile phone manufacturers
2. Get Phone model
3. Get the current language of the mobile system
4. Get the Android system version number
5. Get IMEI serial number of mobile phone
6. Get the list of languages in your phone
Systemutil class
[Java]View PlainCopy
- /**
- * System Tool Class
- * Created by Zhuwentao on 2016-07-18.
- */
- Public class Systemutil {
- /**
- * Get the current phone system language.
- *
- * @return returns the current system language. For example: "Chinese-Chinese" is currently set, then return "ZH-CN"
- */
- public static String Getsystemlanguage () {
- return Locale.getdefault (). GetLanguage ();
- }
- /**
- * Get a list of languages on the current system (locale list)
- *
- * @return Language List
- */
- public Static locale[] Getsystemlanguagelist () {
- return Locale.getavailablelocales ();
- }
- /**
- * Get the current phone system version number
- *
- * @return System version number
- */
- public static String getsystemversion () {
- return Android.os.Build.VERSION.RELEASE;
- }
- /**
- * Get phone model
- *
- * @return Phone model
- */
- public static String Getsystemmodel () {
- return Android.os.Build.MODEL;
- }
- /**
- * Access to mobile phone manufacturers
- *
- * @return Handset Maker
- */
- public static String Getdevicebrand () {
- return Android.os.Build.BRAND;
- }
- /**
- * Get phone IMEI (requires "Android.permission.READ_PHONE_STATE" permission)
- *
- * @return Phone IMEI
- */
- public static String Getimei (Context ctx) {
- Telephonymanager TM = (Telephonymanager) ctx.getsystemservice (Activity.telephony_service);
- if (tm! = null) {
- return Tm.getdeviceid ();
- }
- return null;
- }
- }
Where the acquisition of the phone IMEI needs to add permissions in Androidmanifest.xml:
[HTML]View PlainCopy
- <uses-permission android:name="Android.permission.READ_PHONE_STATE" />
Just call it right when you use these methods.
[Java]View PlainCopy
- Private void Showsystemparameter () {
- String TAG = "system parameter:";
- LOG.E (TAG, "handset maker:" + Systemutil.getdevicebrand ());
- LOG.E (TAG, "phone model:" + Systemutil.getsystemmodel ());
- LOG.E (TAG, "cell phone current system language:" + systemutil.getsystemlanguage ());
- LOG.E (TAG, "Android system version number:" + systemutil.getsystemversion ());
- LOG.E (TAG, "phone IMEI:" + Systemutil.getimei (Getapplicationcontext ()));
- }
return Result:
Android get phone manufacturer, model, Android system version number, IMEI, current system language and other tool classes