Android 获取手机串号

Android 获取手机串号  

   积分 +1  

今天在单位讨论怎么样使用手机进行办公的时候简单呢,突然想到了手机卡的串号,只要通过手机卡的串号就能唯一确定一张手机卡,这样子的话,在登录系统的时候,都不要登录了,只要使用串号就可以了,而且也不会与其它网的手机混在一块,晚上回来就写了一下子,一开始居然报错,后来才想起来,原来是权限的设置问题造成的。具体代码如何:

 Context context = getWindow().getContext();       

TelephonyManager telephonemanage = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);             

  try        {    

   Toast.makeText(this, "MIEI码为:"+telephonemanage.getDeviceId(), 1000).show();     

  }   

    catch(Exception e)        {    

   Log.i("error", e.getMessage()); 

      }

而且需要在AndroidManifest.xml 加入权限才行,内容为:

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

你可能感兴趣的:(Android 获取手机串号)