zoukankan      html  css  js  c++  java
  • 获取手机设备的唯一码(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"/>

  • 相关阅读:
    vue router
    spring web 不定参数
    spring boot添加自定义配置文件
    IntelliJ IDEA查看方法的返回类型
    连接MySql报错->The server time zone value 'XXXXX' is unrecognized...............
    spring boot新建工程中使用mysql,com.mysql.jdbc.Driver标红
    iOS 并发编程之 Operation Queues
    数据安全基础知识总结
    登录令牌 Token 介绍
    常见加密算法
  • 原文地址:https://www.cnblogs.com/benxiong/p/3047016.html
Copyright © 2011-2022 走看看