public class PhoneStateListener extends Object
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.
Modifier and Type | Field and Description |
---|---|
static int |
LISTEN_CALL_FORWARDING_INDICATOR
Listen for changes to the call-forwarding indicator.
|
static int |
LISTEN_CALL_STATE
Listen for changes to the device call state.
|
static int |
LISTEN_CELL_INFO
Listen for changes to observed cell info.
|
static int |
LISTEN_CELL_LOCATION
Listen for changes to the device's cell location.
|
static int |
LISTEN_DATA_ACTIVITY
Listen for changes to the direction of data traffic on the data
connection (cellular).
|
static int |
LISTEN_DATA_CONNECTION_STATE
Listen for changes to the data connection state (cellular).
|
static int |
LISTEN_MESSAGE_WAITING_INDICATOR
Listen for changes to the message-waiting indicator.
|
static int |
LISTEN_NONE
Stop listening for updates.
|
static int |
LISTEN_OTASP_CHANGED
Listen for changes to OTASP mode.
|
static int |
LISTEN_SERVICE_STATE
Listen for changes to the network service state (cellular).
|
static int |
LISTEN_SIGNAL_STRENGTH
Deprecated.
|
static int |
LISTEN_SIGNAL_STRENGTHS
Listen for changes to the network signal strengths (cellular).
|
Constructor and Description |
---|
PhoneStateListener() |
Modifier and Type | Method and Description |
---|---|
void |
onCallForwardingIndicatorChanged(boolean cfi)
Callback invoked when the call-forwarding indicator changes.
|
void |
onCallStateChanged(int state,
String incomingNumber)
Callback invoked when device call state changes.
|
void |
onCellInfoChanged(List<CellInfo> cellInfo)
Callback invoked when a observed cell info has changed,
or new cells have been added or removed.
|
void |
onCellLocationChanged(CellLocation location)
Callback invoked when device cell location changes.
|
void |
onDataActivity(int direction)
Callback invoked when data activity state changes.
|
void |
onDataConnectionStateChanged(int state)
Callback invoked when connection state changes.
|
void |
onDataConnectionStateChanged(int state,
int networkType)
same as above, but with the network type.
|
void |
onMessageWaitingIndicatorChanged(boolean mwi)
Callback invoked when the message-waiting indicator changes.
|
void |
onOtaspChanged(int otaspMode)
The Over The Air Service Provisioning (OTASP) has changed.
|
void |
onServiceStateChanged(ServiceState serviceState)
Callback invoked when device service state changes.
|
void |
onSignalStrengthChanged(int asu)
Deprecated.
|
void |
onSignalStrengthsChanged(SignalStrength signalStrength)
Callback invoked when network signal strengths changes.
|
public static final int LISTEN_NONE
public static final int LISTEN_SERVICE_STATE
@Deprecated public static final int LISTEN_SIGNAL_STRENGTH
LISTEN_SIGNAL_STRENGTHS
READ_PHONE_STATE
public static final int LISTEN_MESSAGE_WAITING_INDICATOR
READ_PHONE_STATE
Example: The status bar uses this to determine when to display the voicemail icon.
public static final int LISTEN_CALL_FORWARDING_INDICATOR
READ_PHONE_STATE
public static final int LISTEN_CELL_LOCATION
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.
public static final int LISTEN_CALL_STATE
READ_PHONE_STATE
public static final int LISTEN_DATA_CONNECTION_STATE
public static final int LISTEN_DATA_ACTIVITY
READ_PHONE_STATE
Example: The status bar uses this to display the appropriate
data-traffic icon.onDataActivity(int)
,
Constant Field Valuespublic static final int LISTEN_SIGNAL_STRENGTHS
Example: The status bar uses this to control the signal-strength icon.
public static final int LISTEN_OTASP_CHANGED
onOtaspChanged(int)
,
Constant Field Valuespublic static final int LISTEN_CELL_INFO
public void onServiceStateChanged(ServiceState serviceState)
@Deprecated public void onSignalStrengthChanged(int asu)
onSignalStrengthsChanged(SignalStrength)
public void onMessageWaitingIndicatorChanged(boolean mwi)
public void onCallForwardingIndicatorChanged(boolean cfi)
public void onCellLocationChanged(CellLocation location)
public void onCallStateChanged(int state, String incomingNumber)
public void onDataConnectionStateChanged(int state)
public void onDataConnectionStateChanged(int state, int networkType)
public void onDataActivity(int direction)
public void onSignalStrengthsChanged(SignalStrength signalStrength)
public void onOtaspChanged(int otaspMode)
otaspMode
- is integer OTASP_UNKNOWN=1
means the value is currently unknown and the system should wait until
OTASP_NEEDED=2 or OTASP_NOT_NEEDED=3 is received before
making the decisision to perform OTASP or not.