Android 如何获取电话序列号(IMEI)
我想通过编程来获取手机序列号,包括我的应用程序的注册配置,以及我的应用程序安装在他们身上的用户和手机的数量 我能拿到吗 我可以获得安装了我的应用程序的手机型号吗?以下是代码:-Android 如何获取电话序列号(IMEI),android,Android,我想通过编程来获取手机序列号,包括我的应用程序的注册配置,以及我的应用程序安装在他们身上的用户和手机的数量 我能拿到吗 我可以获得安装了我的应用程序的手机型号吗?以下是代码:- telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); deviceId = telephonyManager.getDeviceId(); Log.d(TAG, "getDe
telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
deviceId = telephonyManager.getDeviceId();
Log.d(TAG, "getDeviceId() " + deviceId);
phoneType = telephonyManager.getPhoneType();
Log.d(TAG, "getPhoneType () " + phoneType);
试试这个
final TelephonyManager tm =(TelephonyManager)getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
String deviceid = tm.getDeviceId();
请参考这个
将
READ\u PHONE\u STATE
权限添加到AndroidManifest.xml
为IMEI使用以下代码:
public String getIMEI(Context context){
TelephonyManager mngr = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE);
String imei = mngr.getDeviceId();
return imei;
}
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String imei= tm.getDeviceId();
要获取IMEI号码,请使用以下代码
TelephonyManager mngr=getSystemService(Context.Telephony\u service);mngr.getDeviceId()
需要哪些权限?每个人。。安卓6有什么变化吗?我们仍然可以通过某种方式访问IMEI吗?Context.Telephony_服务-->Context.Telephony_服务您可以使用:TelephonyManager tManager=(TelephonyManager)myActivity.getSystemService(Context.Telephony_服务);字符串uid=tManager.getDeviceId();在Android M及以上版本中,用户可能不会授予权限,因此我们需要在访问它们之前进行检查。请查看此答案,此答案在API 26中已被弃用,请使用
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String imei= tm.getDeviceId();