简体   繁体   中英

How to detect phone service state

I read about PhoneStateListener and its onServiceStateChanged callback. One of the possible service state values is STATE_OUT_OF_SERVICE that I need to detect.

Can I get the phone state information without instantiating a listener? In my application, I have no need to be informed punctually for each change on phone state but only need to test if the phone is offline (due to radio signal not available) at a certain moment.

What I would is a (pseudo) TelephonyManager.getServiceState() to call once that unfortunately I cannot find.

Use the ServiceState class, documented here .

Call the getState() function which returns the current state of the phone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM