- 获取手机屏幕高度
- 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();
- }
- .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(); // 手机号码,有的可得,有的不可得
- }
-
获取手机号码和运营商信息
- public String getNativePhoneNumber() {
- String NativePhoneNumber=null;
- NativePhoneNumber=telephonyManager.getLine1Number();
- return NativePhoneNumber;
- }
- <div class="line alt1" style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14.44444465637207px; line-height: 25.98958396911621px;"><pre name="code" class="java">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;
- }</pre><br>
- <br>
- <div></div>
- <pre></pre>
- <br>
- </div>