Android Open Source - CommonLibs Device Utils






From Project

Back to project page CommonLibs.

License

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.

Java Source Code

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??
     *-------------------------*/

}




Java Source Code List

com.alex.common.AppConfig.java
com.alex.common.AppControl.java
com.alex.common.Err.java
com.alex.common.OnHttpRequestReturnListener.java
com.alex.common.activities.BaseActivity.java
com.alex.common.activities.ImageLoadActivity.java
com.alex.common.activities.WebViewActivity.java
com.alex.common.apis.HttpApi.java
com.alex.common.exception.RetErrorException.java
com.alex.common.utils.BackgroundHandler.java
com.alex.common.utils.BaiduMapUtils.java
com.alex.common.utils.DateTimeUtils.java
com.alex.common.utils.DeviceUtils.java
com.alex.common.utils.DialogUtils.java
com.alex.common.utils.FileUtils.java
com.alex.common.utils.ImageUtils.java
com.alex.common.utils.KLog.java
com.alex.common.utils.Misc.java
com.alex.common.utils.NetworkUtils.java
com.alex.common.utils.PrefUtils.java
com.alex.common.utils.ShareUtils.java
com.alex.common.utils.StringUtils.java
com.alex.common.utils.ThreadUtils.java
com.alex.common.utils.ToastUtils.java
com.alex.common.views.ZoomImageView.java