小白 android build类 小结
来源:互联网 发布:建筑工程造价算法 编辑:程序博客网 时间:2024/05/22 07:53
在某些情况下需要我们获取设备信息 ,比如获取手机型号,手机版本等
我们可以利用 android.os.Build 类获取
官方文档地址
1 查看 继承关系
2个嵌套类(内部类)
1、Build.VERSION 各种版本的字符串
2、Build.VERSION_CODES 枚举当前已知的SDK版本代码
22个静态属性
1、BOARD 主板:The name of the underlying board, like “goldfish”.
2、BOOTLOADER 系统启动程序版本号:The system bootloader version number.
3、BRAND 系统定制商:The consumer-visible brand with which the product/hardware will be associated, if any.
4、CPU_ABI cpu架构集:The name of the instruction set (CPU type + ABI convention) of native code.
5、CPU_ABI2 cpu架构集2:The name of the second instruction set (CPU type + ABI convention) of native code.
6、DEVICE 设备参数:The name of the industrial design.
7、DISPLAY 显示屏参数:A build ID string meant for displaying to the user
8、FINGERPRINT 唯一识别码:A string that uniquely identifies this build.
9、HARDWARE 硬件名称:The name of the hardware (from the kernel command line or /proc).
10、HOST
11、ID 修订版本列表:Either a changelist number, or a label like “M4-rc20”.
12、MANUFACTURER 硬件制造商:The manufacturer of the product/hardware.
13、MODEL 手机型号:The end-user-visible name for the end product.
14、PRODUCT 整个产品的名称:The name of the overall product.
15、RADIO 无线电固件版本:The radio firmware version number. 在API14后已过时。使用 getRadioVersion()代替。
16、SERIAL 硬件序列号:A hardware serial number, if available.
17、SUPPORTED_32_BIT_ABIS 32位序列列表 : An ordered list of 32 bit ABIs supported by this device.
18、SUPPORTED_64_BIT_ABIS 64位序列列表: An ordered list of 64 bit ABIs supported by this device.
19、TAGS 标签:Comma-separated tags describing the build, like “unsigned,debug”.
20、TIME
21、TYPE 类型:The type of build, like “user” or “eng”.
22、USER
1个公共方法
public static String getRadioVersion();
日志信息 参考
补充 几个
/* * 获取 设备 uuid * GUID是一个128位长的数字,一般用16进制表示 * UUID是1.5中新增的一个类,在java.util下,用它可以产生一个号称全球唯一的ID * 550E8400-E29B-11D4-A716-446655440000 * */ public static String getuuid() { if (uuid == null) { String s = UUID.randomUUID().toString(); uuid = s.substring(0, 8) + s.substring(9, 13) + s.substring(14, 18) + s.substring(19, 23) + s.substring(24); } return uuid; }
/* * 获取 设备ID * */ public static String getDevideId(Context context) { if (devideId == null) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); devideId = tm.getDeviceId(); } return devideId; }
/** * 获取ip地址 * * @return */ public static String getHostIP() { if (hostIp == null) { try { Enumeration nis = NetworkInterface.getNetworkInterfaces(); InetAddress ia = null; while (nis.hasMoreElements()) { NetworkInterface ni = (NetworkInterface) nis.nextElement(); Enumeration<InetAddress> ias = ni.getInetAddresses(); while (ias.hasMoreElements()) { ia = ias.nextElement(); if (ia instanceof Inet6Address) { continue;// skip ipv6 } String ip = ia.getHostAddress(); if (!"127.0.0.1".equals(ip)) { hostIp = ia.getHostAddress(); break; } } } } catch (SocketException e) { e.printStackTrace(); } } return hostIp; }
/* * 获取 设备ID * */ public static String getDevideId(Context context) { if (devideId == null) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); devideId = tm.getDeviceId(); } return devideId; }
以前很少写文章,也不知道怎么写好,希望做些有意义的事情,不要让自己再坠落了,希望能和大家一起进步。如有错误,希望指出。谢谢!
- 小白 android build类 小结
- 小白 android广播 小结
- android应用类开发小结--android google map小应用
- Android Studio开发Build.gradle小技巧
- 小白之小结
- 小白17年7月29Android编程小结
- android Build类
- Android----Build类
- android的Build类
- Android Build类
- Android Build类
- Android----Build类
- Android Build类
- android studio 使用问题小小结(1)
- 一些常用小类小结
- Android各种小技巧汇总之一: Build.Version.SDK
- Android Build及相关类
- Android Build及相关类
- VMware怎么安装VMware tools
- 谈一谈Elasticsearch的集群部署
- Android性能优化之实现一个线程多个任务--HandlerThread
- MySQL-Join
- Android网络定位或GPS定位
- 小白 android build类 小结
- PHP文件操作-读取数据库文件路径复制到另一个目录
- Java StringBuffer和StringBuilder类
- Android Studio2.0应用结构解析
- 获取状态栏高度的方法
- vim 基本操作
- 关于redhat 文件名进行列表查看 日期显示乱码解决
- nexus的搭建
- 读书 -《传习录》