Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何获取电话序列号(IMEI)_Android - Fatal编程技术网

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();