- 获取手机屏幕高度
1. private void getWeithAndHeight(){
2. //这种方式在service中无法使用,
3. DisplayMetrics dm = new DisplayMetrics();
4. getWindowManager().getDefaultDisplay().getMetrics(dm);
5. String width = dm.widthPixels; //宽
6. String height = dm.heightPixels; //高
7.
8. //在service中也能得到高和宽
9. WindowManager mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
10. width = mWindowManager.getDefaultDisplay().getWidth();
11. height = mWindowManager.getDefaultDisplay().getHeight();
12. }
- .IMEI号,IESI号,手机型号等
•
1. private void getInfo() {
2. TelephonyManager mTm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
3. String imei = mTm.getDeviceId();
4. String imsi = mTm.getSubscriberId();
5. String mtype = android.os.Build.MODEL; // 手机型号
6. String numer = mTm.getLine1Number(); // 手机号码,有的可得,有的不可得
7. }
获取手机号码和运营商信息
1. public String getNativePhoneNumber() {
2. String NativePhoneNumber=null;
3. NativePhoneNumber=telephonyManager.getLine1Number();
4. return NativePhoneNumber;
5. }
1. "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() {
2. String ProvidersName = null;
3. // 返回唯一的用户ID;就是这张卡的编号的
4. IMSI = telephonyManager.getSubscriberId();
5. // IMSI号前面3位460是国家,紧接着后面2位00 02是中国移动,01是中国联通,03是中国电信。
6. System.out.println(IMSI);
7. if (IMSI.startsWith("46000") || IMSI.startsWith("46002")) {
8. ProvidersName = "中国移动";
9. } else if (IMSI.startsWith("46001")) {
10. ProvidersName = "中国联通";
11. } else if (IMSI.startsWith("46003")) {
12. ProvidersName = "中国电信";
13. }
14. return ProvidersName;
15. }
16.
17.
18.
19.
20.
21.
标签:startsWith,dm,String,信息,ProvidersName,mTm,手机,Android,IMSI
From: https://blog.51cto.com/u_548275/6237779