获取手机设备的唯一码(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"/>

posted @ 2013-04-27 14:22  kanrun  阅读(573)  评论(0编辑  收藏  举报