/** 设置userId */ public void setUserId() { TelephonyManager telephonemanager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); try { String IMSI = telephonemanager.getSubscriberId(); // 获取手机国际识别码IMEI userId = "chatRobot" + IMSI; } catch (Exception e) { e.printStackTrace(); Random random = new Random(100); Long currentTimeMillis = System.currentTimeMillis(); userId = random.toString() + currentTimeMillis.toString(); } }