类 DeviceUtils


  • public final class DeviceUtils
    extends Object
    • 方法详细资料

      • isDeviceRooted

        public static boolean isDeviceRooted()
        Return whether device is rooted.
        返回:
        true: yes
        false: no
      • isAdbEnabled

        @RequiresApi(api=17)
        public static boolean isAdbEnabled​(Context context)
        Return whether ADB is enabled.
        返回:
        true: yes
        false: no
      • getSDKVersionName

        public static String getSDKVersionName()
        Return the version name of device's system.
        返回:
        the version name of device's system
      • getSDKVersionCode

        public static int getSDKVersionCode()
        Return version code of device's system.
        返回:
        version code of device's system
      • getAndroidID

        public static String getAndroidID​(Context context)
        Return the android id of device.
        返回:
        the android id of device
      • getMacAddress

        @RequiresPermission(allOf={"android.permission.ACCESS_WIFI_STATE","android.permission.CHANGE_WIFI_STATE"})
        public static String getMacAddress​(Context context)
        Return the MAC address.

        Must hold <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />, <uses-permission android:name="android.permission.INTERNET" />, <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

        返回:
        the MAC address
      • getMacAddress

        @RequiresPermission(allOf="android.permission.ACCESS_WIFI_STATE")
        public static String getMacAddress​(Context context,
                                           String... excepts)
        Return the MAC address.

        Must hold <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />, <uses-permission android:name="android.permission.INTERNET" />

        返回:
        the MAC address
      • getManufacturer

        public static String getManufacturer()
        Return the manufacturer of the product/hardware.

        e.g. Xiaomi

        返回:
        the manufacturer of the product/hardware
      • getModel

        public static String getModel()
        Return the model of device.

        e.g. MI2SC

        返回:
        the model of device
      • getABIs

        public static String[] getABIs()
        Return an ordered list of ABIs supported by this device. The most preferred ABI is the first element in the list.
        返回:
        an ordered list of ABIs supported by this device
      • isTablet

        public static boolean isTablet()
        Return whether device is tablet.
        返回:
        true: yes
        false: no
      • isEmulator

        public static boolean isEmulator​(Context context)
        Return whether device is emulator.
        返回:
        true: yes
        false: no
      • isDevelopmentSettingsEnabled

        @RequiresApi(api=17)
        public static boolean isDevelopmentSettingsEnabled​(Context context)
        Whether user has enabled development settings.
        返回:
        whether user has enabled development settings.
      • getUniqueDeviceId

        public static String getUniqueDeviceId​(Context context)
        Return the unique device id.
        {1}{UUID(macAddress)}
        {2}{UUID(androidId )}
        {9}{UUID(random    )}
        返回:
        the unique device id
      • getUniqueDeviceId

        public static String getUniqueDeviceId​(Context context,
                                               String prefix)
        Return the unique device id.
        android 10 deprecated {prefix}{1}{UUID(macAddress)}
        {prefix}{2}{UUID(androidId )}
        {prefix}{9}{UUID(random    )}
        参数:
        prefix - The prefix of the unique device id.
        返回:
        the unique device id
      • getUniqueDeviceId

        public static String getUniqueDeviceId​(Context context,
                                               boolean useCache)
        Return the unique device id.
        {1}{UUID(macAddress)}
        {2}{UUID(androidId )}
        {9}{UUID(random    )}
        参数:
        useCache - True to use cache, false otherwise.
        返回:
        the unique device id
      • getUniqueDeviceId

        public static String getUniqueDeviceId​(Context context,
                                               String prefix,
                                               boolean useCache)
        Return the unique device id.
        android 10 deprecated {prefix}{1}{UUID(macAddress)}
        {prefix}{2}{UUID(androidId )}
        {prefix}{9}{UUID(random    )}
        参数:
        prefix - The prefix of the unique device id.
        useCache - True to use cache, false otherwise.
        返回:
        the unique device id
      • isSameDevice

        @RequiresPermission(allOf={"android.permission.ACCESS_WIFI_STATE","android.permission.INTERNET","android.permission.CHANGE_WIFI_STATE"})
        public static boolean isSameDevice​(Context context,
                                           String uniqueDeviceId)