1
1
package com .lennoo .rno ;
2
2
3
3
import android .content .Context ;
4
+ import android .content .Intent ;
4
5
import android .os .Build ;
5
6
import android .support .v7 .app .AppCompatActivity ;
6
7
import android .os .Bundle ;
8
+ import android .telephony .CellInfo ;
7
9
import android .telephony .CellInfoGsm ;
10
+ import android .telephony .CellInfoLte ;
8
11
import android .telephony .CellSignalStrengthGsm ;
9
12
import android .telephony .TelephonyManager ;
10
13
import android .view .ViewDebug ;
@@ -30,6 +33,9 @@ protected void onCreate(Bundle savedInstanceState) {
30
33
TextView textDataState = (TextView )findViewById (R .id .datastate );
31
34
TextView textDataActivity = (TextView )findViewById (R .id .dataactivity );
32
35
TextView textGsmSign = (TextView )findViewById (R .id .gsmsign );
36
+ TextView textTac = (TextView )findViewById (R .id .tac );
37
+ TextView textPci = (TextView )findViewById (R .id .pci );
38
+ TextView textRsrp = (TextView )findViewById (R .id .rsrp );
33
39
34
40
textPhoneModel .setText ("手机:" +Build .MODEL );
35
41
textSystemVer .setText ("系统:" +Build .VERSION .RELEASE );
@@ -40,10 +46,22 @@ protected void onCreate(Bundle savedInstanceState) {
40
46
textDataState .setText ("数据状态:" +telephonyInfo .getDataState ());
41
47
textDataActivity .setText ("数据活动:" +telephonyInfo .getDataActivity ());
42
48
43
- TelephonyManager telephonyManager = (TelephonyManager )this .getSystemService (Context .TELEPHONY_SERVICE );
44
- CellInfoGsm cellinfogsm = (CellInfoGsm )telephonyManager .getAllCellInfo ().get (0 );
45
- CellSignalStrengthGsm cellSignalStrengthGsm = cellinfogsm .getCellSignalStrength ();
46
- int gsmsign = cellSignalStrengthGsm .getDbm ();
47
- textGsmSign .setText ("Sign" + Integer .toString (gsmsign ));
49
+ TelephonyManager tm = (TelephonyManager )this .getSystemService (Context .TELEPHONY_SERVICE );
50
+ CellInfo cellinfo = tm .getAllCellInfo ().get (0 );
51
+ int sign = 0 ;
52
+ int ta = 0 ;
53
+ int tac = 0 ;
54
+ if (cellinfo instanceof CellInfoGsm ) {
55
+ sign = ((CellInfoGsm )cellinfo ).getCellSignalStrength ().getDbm ();
56
+ } else if (cellinfo instanceof CellInfoLte ) {
57
+ CellInfoLte cellInfoLte = (CellInfoLte )cellinfo ;
58
+ sign = cellInfoLte .getCellSignalStrength ().getDbm ();
59
+ ta = cellInfoLte .getCellSignalStrength ().getTimingAdvance ();
60
+ tac = cellInfoLte .getCellIdentity ().getTac ();
61
+
62
+ }
63
+ textGsmSign .setText ("Sign" + Integer .toString (sign ));
64
+ textPci .setText ("TA:" +Integer .toString (ta ));
65
+ textTac .setText ("TAC:" + Integer .toString (tac ));
48
66
}
49
67
}
0 commit comments