我只贴了关键代码,其实就是import android.telephony.ServiceState

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
ServiceState ss=new ServiceState();
                int s;
                s=ss.getState();
                switch(s)
                {
                case ServiceState.STATE_EMERGENCY_ONLY:
                    Toast toast1=Toast.makeText(GSMDetector.this,"Emegency_only", Toast.LENGTH_SHORT);
                    toast1.show();
                    break;
                case ServiceState.STATE_IN_SERVICE:
                    Toast toast2=Toast.makeText(GSMDetector.this,"in_Service", Toast.LENGTH_SHORT);
                    toast2.show();
                    break;
                case ServiceState.STATE_OUT_OF_SERVICE:
                    Toast toast3=Toast.makeText(GSMDetector.this,"out_of_Service", Toast.LENGTH_SHORT);
                    toast3.show();
                    break;
                case ServiceState.STATE_POWER_OFF:
                    Toast toast4=Toast.makeText(GSMDetector.this,"Power_off", Toast.LENGTH_SHORT);
                    toast4.show();
                    break;