获取手机设备的唯一码(IMIE )的方法

public class MainActivity extends
  Activity {

 @Override
 protected void onCreate(
   Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  TextView textView =(TextView) findViewById(R.id.test);
  TelephonyManager tm = (TelephonyManager) this 

       .getSystemService(Context.TELEPHONY_SERVICE);//     

       String str = ""; 

       str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";   

       str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";   

       str += "Line1Number = " + tm.getLine1Number() + "\n";   

       str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";   

       str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";   

       str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";   

       str += "NetworkType = " + tm.getNetworkType() + "\n";   

       str += "PhoneType = " + tm.getPhoneType() + "\n";   

       str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";   

       str += "SimOperator = " + tm.getSimOperator() + "\n";   

       str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";   

       str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";   

       str += "SimState = " + tm.getSimState() + "\n";   

       str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";   

       str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";   

    

       textView.setText(str);
 }

}

 

记得在配置AndroidManifest.xml中添加读取电话的权限:

<uses-permission  android:name="android.permission.READ_PHONE_STATE"/>

转载于:https://www.cnblogs.com/benxiong/archive/2013/04/27/3047016.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值