最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Android获取本机号码问题和获取系统版本信息
时间:2013-07-29 编辑:简简单单 来源:一聚教程网
1、使用TelephonyManager提供的方法,核心代码:
代码如下 | 复制代码 |
TelephonyManager tm = (TelephonyManager) this.getSystemService(TELEPHONY_SERVICE); String imei = tm.getDeviceId(); //取出IMEI Log.d(TAG, "IMEI:"+imei); String tel = tm.getLine1Number(); //取出MSISDN,很可能为空 Log.d(TAG, "MSISDN:"+tel); String iccid =tm.getSimSerialNumber(); //取出ICCID Log.d(TAG, "ICCID:"+iccid); String imsi =tm.getSubscriberId(); //取出IMSI Log.d(TAG, "IMSI:"+imsi); |
2、加入权限
在manifest.xml文件中要添加
手机型号 Build.MODEL
代码如下 | 复制代码 |
String MODEL The end-user-visible name for the end product. |
sdk版本 Build.VERSION.SDK
代码如下 | 复制代码 |
String SDK This constant is deprecated. Use SDK_INT to easily get this as an integer. |
frimware版本号(系统版本号) Build.VERSION.RELEASE
代码如下 | 复制代码 |
String RELEASE The user-visible version string. |
获取手机的其他信息:
代码如下 | 复制代码 |
private void getPhoneStatus(){ TelephonyManager phoneMgr=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE); |
Build中包括 硬件厂商,硬件编号,序列号等很多信息。调用方法也很简单,和上面类似的。
相关文章
- Android SdkVersion的区别及获取版本信息方法 06-21
- Android基于TextView不获取焦点实现跑马灯效果 05-10
- Android中获取资源 id 及资源 id 的动态获取 03-01
- Android ListView 子控件onClick正确获取position的方法 02-12
- sora软件价格介绍 02-22
- sora官网入口地址一览 02-22