android 如何得到手机的信息..

public class PhoneState {

 private SharedPreferences mdata;
 private TelephonyManager mPhoneManager;
 LogUtil logUtil=new LogUtil();//rizhi
 @SuppressWarnings("static-access")
 public PhoneState(Context context) {
  mdata = PreferenceManager.getDefaultSharedPreferences(context);
  mPhoneManager = (TelephonyManager) context
    .getSystemService(context.TELEPHONY_SERVICE);
 }

 // 用户ID
 public int getUsrid() {
  
  return mdata.getInt("uid", 0);
 }

 // 获得imei号
 public String getPhoneid1() {
  logUtil.writeFileToSD("imei"+mPhoneManager.getDeviceId());
  return mPhoneManager.getDeviceId();
 }

 // 获得手机号
 public String getPhoneid2() {
  logUtil.writeFileToSD("手机号"+mPhoneManager.getLine1Number());
  return mPhoneManager.getLine1Number();
 }

 // 获得手机型号
 public String getUseragent() {
  return Build.MODEL;
 }

 public String getIMSI() {
  String myIMSI = mPhoneManager.getSubscriberId();
  logUtil.writeFileToSD("imsi"+myIMSI);
  return myIMSI;
 }

 // 获取短信中心号码
 public String getSmsCenterNum() {
  return new SmsMessage().getServiceCenterAddress();
 }
 // 获得ip
 public String getIp() {
  try {
   for (Enumeration<NetworkInterface> en = NetworkInterface
     .getNetworkInterfaces(); en.hasMoreElements();) {
    NetworkInterface intf = en.nextElement();
    for (Enumeration<InetAddress> enumIpAddr = intf
      .getInetAddresses(); enumIpAddr.hasMoreElements();) {
     InetAddress inetAddress = enumIpAddr.nextElement();
     if (!inetAddress.isLoopbackAddress()) {
      return inetAddress.getHostAddress().toString();
     }
    }
   }
  } catch (Exception e) {
  }
  return "0.0.0.0";
 }
}

你可能感兴趣的:(android)