返回列表 发帖

[实例] 获取手机设备的唯一码(uniquely_code)的方法

在这个接口说明中,需要传递一个手机设备的唯一码(uniquely_code)的参数,一般来说,我们可以使用IMIE,其获取方法也比较简单,代码如下:
  1. public void fetch_status(){  
  2.     TelephonyManager tm = (TelephonyManager) this  
  3.     .getSystemService(Context.TELEPHONY_SERVICE);//      
  4.     String str = "";  
  5.     str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";   
  6.     str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";   
  7.     str += "Line1Number = " + tm.getLine1Number() + "\n";   
  8.     str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";   
  9.     str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";   
  10.     str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";   
  11.     str += "NetworkType = " + tm.getNetworkType() + "\n";   
  12.     str += "honeType = " + tm.getPhoneType() + "\n";   
  13.     str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";   
  14.     str += "SimOperator = " + tm.getSimOperator() + "\n";   
  15.     str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";   
  16.     str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";   
  17.     str += "SimState = " + tm.getSimState() + "\n";   
  18.     str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";   
  19.     str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";   
  20.     TextView sys = (TextView) findViewById(R.id.sys);  
  21.     sys.setText(str);  
  22. }  
复制代码
注意:
str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";


希望对大家有用。
啥时变成机器人....
懂点安全,对互联网还心存幻想的程序员…
Blog: http://iceskysl.1sters.com

需要权限
积思顿悟

TOP

再来个不需要权限的:
http://iceskysl.1sters.com/?action=show&id=455

In some case,you may want do get  Uniquely Identifying  for a  'real' android phone,and you can do it like this:
In Android.Provider.Settings.System we have some interesting values that could be of use, one specifically is “Android_ID”. From the documentation it is the following;
String ANDROID_ID The Android ID (a unique 64-bit value) as a hex string. “android_id”
  1. import Android.Provider.Settings.System;  
  2. ...  
  3. String Android_ID = System.getString(this.getContentResolver(), System.ANDROID_ID);  
复制代码
Also, note that in an emulator this will return “null”, though a real device will return an actual value. The nice thing about this tid-bit of code is that you are not required any special permissions to call it, since it’s essentially a passive call to get information. No write access is (obviously) required.
啥时变成机器人....
懂点安全,对互联网还心存幻想的程序员…
Blog: http://iceskysl.1sters.com

TOP

在开发中,应用要和设备绑定的话,只能获取IMEI号,是不是只能使用这个str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
还有其他方法吗?

TOP

NULL可以么?
用模拟器的话,System.getString(this.getContentResolver(), System.ANDROID_ID);  返回的是null

TOP

哈哈,收藏先,以后可能需要

TOP

正在找相关资料耶,太谢谢老

TOP

NULL可以么?
用模拟器的话,System.getString(this.getContentResolver(), System.ANDROID_ID);  返回的是 ...
yanx730 发表于 2009-10-28 18:40


NULL不可以哦~

TOP

我觉得收费软件绑定SIM或者电话号码比较人性化。有可能换一台Android手机,继续使用原来的软件和串号......

随便说说

TOP

电话号码算隐私信息了~比较敏感~
管不了天, 也管不了地,最大目标是管好eoe

TOP

tm.getLine1Number()这个方法在WCDMA的手机获取不到手机号码啊。
认真做自己!!!

TOP

学习啦

TOP

很好啊。多多提供好的应用接口啊。

TOP

有用的好帖~~~顶起
我的Android,我做主

TOP

先收藏了,以后估计会用到
谢谢楼主分享
每天进步一点点

TOP

返回列表

强烈推荐 关闭


到货啦,货到啦!!《Its Android Time—创赢路线》

到货啦,货到啦! 早上接到出版社通知,说《Its Android Time》在china-pub上到货了! 加上推荐序和前言等部分,差不多600页的样子,拿在手里够厚重的; 购买地 ...


查看