没有合适的资源?快使用搜索试试~ 我知道了~
首页Android获得设备状态信息、Mac地址、IP地址的方法
前言 在APP开发时,经常会遇到要获取手机状态信息的场景,像升级时获取版本号,像发生异常时要收集手机信息等等。有些软件还要根据Mac地址来判定当前用户以前是否登录过。下面将一一介绍获取这些手机状态信息的方法。 1 通过build获取手机硬件信息 运用反射获取Build信息,然后从build中得到对应字段的值。这种情况适用于获取所有的build信息。 或者直接调用Build类直接拿里面的字段名,如:android.os.Build.MODEL; // 手机型号 。这是为了获取单独某个手机信息的方法,直接调用Build的字段即可拿到对应信息,简单快捷。 别忘了加权限 <uses-pe
资源详情
资源评论
资源推荐

Android获得设备状态信息、获得设备状态信息、Mac地址、地址、IP地址的方法地址的方法
前言前言
在APP开发时,经常会遇到要获取手机状态信息的场景,像升级时获取版本号,像发生异常时要收集手机信息等等。有些软件
还要根据Mac地址来判定当前用户以前是否登录过。下面将一一介绍获取这些手机状态信息的方法。
1 通过通过build获取手机硬件信息获取手机硬件信息
运用反射获取Build信息,然后从build中得到对应字段的值。这种情况适用于获取所有的build信息。
或者直接调用Build类直接拿里面的字段名,如:android.os.Build.MODEL; // 手机型号 。这是为了获取单独某个手机信息的方
法,直接调用Build的字段即可拿到对应信息,简单快捷。
别忘了加权限
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
下面是Build类的字段所对应的信息
String BOARD The name of the underlying board, like "goldfish".基板名
String BOOTLOADER The system bootloader version number.
String BRAND The brand (e.g., carrier) the software is customized for, if any.品牌名
String CPU_ABI The name of the instruction set (CPU type + ABI convention) of native code.
String CPU_ABI2 The name of the second instruction set (CPU type + ABI convention) of native code.
String DEVICE The name of the industrial design.品牌型号名,如小米4对应cancro
String DISPLAY A build ID string meant for displaying to the user
String FINGERPRINT A string that uniquely identifies this build.包含制造商,设备名,系统版本等诸多信息
String HARDWARE The name of the hardware (from the kernel command line or /proc).
String HOST
String ID Either a changelist number, or a label like "M4-rc20".
String MANUFACTURER The manufacturer of the product/hardware.
String MODEL The end-user-visible name for the end product.
String PRODUCT The name of the overall product.
String RADIO The radio firmware version number.
String SERIAL A hardware serial number, if available.
String TAGS Comma-separated tags describing the build, like "unsigned,debug".
long TIME 当前时间,毫秒值
String TYPE The type of build, like "user" or "eng".
String UNKNOWN Value used for when a build property is unknown.
String USER
//运用反射得到build类里的字段
Field[] fields = Build.class.getDeclaredFields();
//遍历字段名数组
for (Field field : fields) {
try {
//将字段都设为public可获取
field.setAccessible(true);
//filed.get(null)得到的即是设备信息
haspmap.put(field.getName(), field.get(null).toString());
Log.d("CrashHandler", field.getName() + " : " + field.get(null));
} catch (Exception e) {
}
}
下面是小米4对应的设备信息
D/CrashHandler: BOARD : MSM8974
D/CrashHandler: BOOTLOADER : unknown
D/CrashHandler: BRAND : Xiaomi
D/CrashHandler: CPU_ABI : armeabi-v7a
D/CrashHandler: CPU_ABI2 : armeabi
D/CrashHandler: DEVICE : cancro
D/CrashHandler: DISPLAY : MMB29M
D/CrashHandler: FINGERPRINT : Xiaomi/cancro_wc_lte/cancro:6.0.1/MMB29M/V8.1.3.0.MXDCNDI:user/release-keys
D/CrashHandler: HARDWARE : qcom
D/CrashHandler: HOST : c3-miui-ota-bd43
D/CrashHandler: ID : MMB29M
D/CrashHandler: IS_DEBUGGABLE : false
D/CrashHandler: MANUFACTURER : Xiaomi
D/CrashHandler: MODEL : MI 4LTE
D/CrashHandler: PRODUCT : cancro_wc_lte
D/CrashHandler: RADIO : unknown
//设备的序列号码-SERIAL
D/CrashHandler: SERIAL : abcdefgh















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0