Explanation
To avoid duplicate content in this section use on a project as this section of the project
Said the current project that is behind the project in this section.
Open on a project, a project of this section
Basics first open test of APP inside source inside the project
copy
First, copy the first test of APP inside source inside MyMqttClient to the current project
Second, the phone's IMEI source which is used as a ClientID MQTT, and get a copy of the source code inside the IMEI
Code into the current project
public static String TelephonyIMEI = "" ; // get phone IMEI
= GetTelephonyIMEI TelephonyIMEI (getApplicationContext ()); // get phone IMEI
/*获取手机IMEI号*/ private String getTelephonyIMEI(Context context) { String id = "IMEI"; TelephonyManager mTelephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) { if (mTelephony.getDeviceId() != null) { id = mTelephony.getDeviceId(); } } else { id = Settings.Secure.getString(context.getApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID); } return id; }
三,添加权限
电脑卡顿,正在重启