-
获取手机屏幕高度 - private
void getWeithAndHeight(){ -
//这种方式在service中无法使用, -
DisplayMetrics dm = new DisplayMetrics(); -
getWindowManager().getDefaultDisplay().getMetrics(dm); -
String width = dm.widthPixels; //宽 -
String height = dm.heightPixels; //高 -
-
//在service中也能得到高和宽 -
WindowManager mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); -
width = mWindowManager.getDefaultDisplay().getWidth(); -
height = mWindowManager.getDefaultDisplay().getHeight(); -
}
private void getWeithAndHeight(){ //这种方式在service中无法使用, DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); String width = dm.widthPixels; //宽 String height = dm.heightPixels; //高 //在service中也能得到高和宽 WindowManager mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); width = mWindowManager.getDefaultDisplay().getWidth(); height = mWindowManager.getDefaultDisplay().getHeight(); }
- private
- .IMEI号,IESI号,手机型号等
- private
void getInfo() { -
TelephonyManager mTm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); -
String imei = mTm.getDeviceId(); -
String imsi = mTm.getSubscriberId(); -
String mtype = android.os.Build.MODEL; // 手机型号 -
String numer = mTm.getLine1Number(); // 手机号码,有的可得,有的不可得 -
}
private void getInfo() { TelephonyManager mTm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); String imei = mTm.getDeviceId(); String imsi = mTm.getSubscriberId(); String mtype = android.os.Build.MODEL; // 手机型号 String numer = mTm.getLine1Number(); // 手机号码,有的可得,有的不可得 }
- private
-
获取手机号码和运营商信息
[java] view plaincopyprint?
- public
String getNativePhoneNumber() { -
String NativePhoneNumber=null; -
NativePhoneNumber=telephonyManager.getLine1Number(); -
return NativePhoneNumber; -
}
public String getNativePhoneNumber() { String NativePhoneNumber=null; NativePhoneNumber=telephonyManager.getLine1Number(); return NativePhoneNumber; }
- "LINE-HEIGHT:
25px; FONT-FAMILY: Arial; COLOR: rgb(51,51,51); FONT-SIZE: 14px" class="line alt1" sizcache="2" sizset="4">class=java name="code">public String getProvidersName() { -
String ProvidersName = null; -
// 返回唯一的用户ID;就是这张卡的编号的 -
IMSI = telephonyManager.getSubscriberId(); -
// IMSI号前面3位460是国家,紧接着后面2位00 02是中国移动,01是中国联通,03是中国电信。 -
System.out.println(IMSI); -
if (IMSI.startsWith("46000") || IMSI.startsWith("46002")) { -
ProvidersName = "中国移动"; -
} else if (IMSI.startsWith("46001")) { -
ProvidersName = "中国联通"; -
} else if (IMSI.startsWith("46003")) { -
ProvidersName = "中国电信"; -
} -
return ProvidersName; -
}
-
-
-
- public
Android手机信息
最新推荐文章于 2024-06-06 14:03:12 发布