java.lang.Object | |
↳ | android.telephony.PhoneStateListener |
A listener class for monitoring changes in specific telephony states on the device, including service state, signal strength, message waiting indicator (voicemail), and others.
Override the methods for the state that you wish to receive updates for, and
pass your PhoneStateListener object, along with bitwise-or of the LISTEN_
flags to TelephonyManager.listen()
.
Note that access to some telephony information is permission-protected. Your application won't receive updates for protected information unless it has the appropriate permissions declared in its manifest file. Where permissions apply, they are noted in the appropriate LISTEN_ flags.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | LISTEN_CALL_FORWARDING_INDICATOR | Listen for changes to the call-forwarding indicator. | |||||||||
int | LISTEN_CALL_STATE | Listen for changes to the device call state. | |||||||||
int | LISTEN_CELL_INFO | Listen for changes to observed cell info. | |||||||||
int | LISTEN_CELL_LOCATION | Listen for changes to the device's cell location. Note that this will result in frequent callbacks to the listener. | |||||||||
int | LISTEN_DATA_ACTIVITY | Listen for changes to the direction of data traffic on the data connection (cellular). | |||||||||
int | LISTEN_DATA_CONNECTION_STATE | Listen for changes to the data connection state (cellular). | |||||||||
int | LISTEN_MESSAGE_WAITING_INDICATOR | Listen for changes to the message-waiting indicator. | |||||||||
int | LISTEN_NONE | Stop listening for updates. | |||||||||
int | LISTEN_SERVICE_STATE | Listen for changes to the network service state (cellular). | |||||||||
int | LISTEN_SIGNAL_STRENGTH |
This constant was deprecated
in API level 7.
by LISTEN_SIGNAL_STRENGTHS
|
|||||||||
int | LISTEN_SIGNAL_STRENGTHS | Listen for changes to the network signal strengths (cellular). |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a PhoneStateListener for the Phone with the default subscription.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Callback invoked when the call-forwarding indicator changes.
| |||||||||||
Callback invoked when device call state changes.
| |||||||||||
Callback invoked when a observed cell info has changed,
or new cells have been added or removed.
| |||||||||||
Callback invoked when device cell location changes.
| |||||||||||
Callback invoked when data activity state changes.
| |||||||||||
Callback invoked when connection state changes.
| |||||||||||
same as above, but with the network type.
| |||||||||||
Callback invoked when the message-waiting indicator changes.
| |||||||||||
Callback invoked when device service state changes.
| |||||||||||
This method was deprecated
in API level 5.
Use
onSignalStrengthsChanged(SignalStrength)
| |||||||||||
Callback invoked when network signal strengths changes.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Listen for changes to the call-forwarding indicator.
Requires Permission: READ_PHONE_STATE
Listen for changes to the device call state.
Requires Permission: READ_PHONE_STATE
Listen for changes to observed cell info.
Listen for changes to the device's cell location. Note that this will result in frequent callbacks to the listener.
Requires Permission: ACCESS_COARSE_LOCATION
If you need regular location updates but want more control over
the update interval or location precision, you can set up a listener
through the location manager
instead.
Listen for changes to the direction of data traffic on the data connection (cellular).
Requires Permission: READ_PHONE_STATE
Example: The status bar uses this to display the appropriate
data-traffic icon.
Listen for changes to the data connection state (cellular).
Listen for changes to the message-waiting indicator.
Requires Permission: READ_PHONE_STATE
Example: The status bar uses this to determine when to display the voicemail icon.
Stop listening for updates.
Listen for changes to the network service state (cellular).
This constant was deprecated
in API level 7.
by LISTEN_SIGNAL_STRENGTHS
Listen for changes to the network signal strength (cellular).
Requires Permission: READ_PHONE_STATE
Listen for changes to the network signal strengths (cellular).
Example: The status bar uses this to control the signal-strength icon.
Create a PhoneStateListener for the Phone with the default subscription. This class requires Looper.myLooper() not return null. To supply your own non-null looper use PhoneStateListener(Looper looper) below.
Callback invoked when the call-forwarding indicator changes.
Callback invoked when device call state changes.
Callback invoked when a observed cell info has changed, or new cells have been added or removed.
cellInfo | is the list of currently visible cells. |
---|
Callback invoked when device cell location changes.
Callback invoked when data activity state changes.
Callback invoked when connection state changes.
same as above, but with the network type. Both called.
Callback invoked when the message-waiting indicator changes.
Callback invoked when device service state changes.
This method was deprecated
in API level 5.
Use onSignalStrengthsChanged(SignalStrength)
Callback invoked when network signal strength changes.
Callback invoked when network signal strengths changes.