Back to project page CommonLibs.
The source code is released under:
Apache License
If you think the Android project CommonLibs listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.alex.common.utils; //w ww . j a va 2s . c om import android.content.Context; import android.text.TextUtils; /** * ????? * @author caisenchuan */ public class DeviceUtils { /*-------------------------- * ??? *-------------------------*/ /*-------------------------- * ????? *-------------------------*/ /*-------------------------- * ???????? *-------------------------*/ /*-------------------------- * public?? *-------------------------*/ /** * ???????? */ public static int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } /** * ????????????4.4???? * @return */ public static boolean underAndroid44() { if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) { return true; } else { return false; } } /** * ????????????4.3???? * @return */ public static boolean underAndroid43() { if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) { return true; } else { return false; } } /** * ????????????????????????? * @param context * @return */ public static String umengGetDeviceInfo(Context context) { try { org.json.JSONObject json = new org.json.JSONObject(); android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); String device_id = tm.getDeviceId(); android.net.wifi.WifiManager wifi = (android.net.wifi.WifiManager) context .getSystemService(Context.WIFI_SERVICE); String mac = wifi.getConnectionInfo().getMacAddress(); json.put("mac", mac); if (TextUtils.isEmpty(device_id)) { device_id = mac; } if (TextUtils.isEmpty(device_id)) { device_id = android.provider.Settings.Secure.getString( context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); } json.put("device_id", device_id); return json.toString(); } catch (Exception e) { e.printStackTrace(); } return null; } /*-------------------------- * protected??packet?? *-------------------------*/ /*-------------------------- * private?? *-------------------------*/ }