Build 1.0_r1(from source)

android.telephony
Class PhoneStateListener

java.lang.Object
  extended by android.telephony.PhoneStateListener
Direct Known Subclasses:
AndroidRadioDataProvider

public class PhoneStateListener
extends Object

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.


Field Summary
(package private)  IPhoneStateListener callback
          The callback methods need to be called on the handler thread where this object was created.
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_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_SERVICE_STATE
          Listen for changes to the network service state (cellular).
static int LISTEN_SIGNAL_STRENGTH
          Listen for changes to the network signal strength (cellular).
(package private)  Handler mHandler
           
 
Constructor Summary
PhoneStateListener()
           
 
Method Summary
 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 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 onMessageWaitingIndicatorChanged(boolean mwi)
          Callback invoked when the message-waiting indicator changes.
 void onServiceStateChanged(ServiceState serviceState)
          Callback invoked when device service state changes.
 void onSignalStrengthChanged(int asu)
          Callback invoked when network signal strength changes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LISTEN_NONE

public static final int LISTEN_NONE
Stop listening for updates.

See Also:
Constant Field Values

LISTEN_SERVICE_STATE

public static final int LISTEN_SERVICE_STATE
Listen for changes to the network service state (cellular).

See Also:
onServiceStateChanged(android.telephony.ServiceState), ServiceState, Constant Field Values

LISTEN_SIGNAL_STRENGTH

public static final int LISTEN_SIGNAL_STRENGTH
Listen for changes to the network signal strength (cellular).

Example: The status bar uses this to control the signal-strength icon.

See Also:
onSignalStrengthChanged(int), Constant Field Values

LISTEN_MESSAGE_WAITING_INDICATOR

public static final int LISTEN_MESSAGE_WAITING_INDICATOR
Listen for changes to the message-waiting indicator.

Example: The status bar uses this to determine when to display the voicemail icon.

See Also:
onMessageWaitingIndicatorChanged(boolean), Constant Field Values

LISTEN_CALL_FORWARDING_INDICATOR

public static final int LISTEN_CALL_FORWARDING_INDICATOR
Listen for changes to the call-forwarding indicator.

See Also:
onCallForwardingIndicatorChanged(boolean), Constant Field Values

LISTEN_CELL_LOCATION

public static final int LISTEN_CELL_LOCATION
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.

See Also:
onCellLocationChanged(android.telephony.CellLocation), Constant Field Values

LISTEN_CALL_STATE

public static final int LISTEN_CALL_STATE
Listen for changes to the device call state.

See Also:
onCallStateChanged(int, java.lang.String), Constant Field Values

LISTEN_DATA_CONNECTION_STATE

public static final int LISTEN_DATA_CONNECTION_STATE
Listen for changes to the data connection state (cellular).

See Also:
onDataConnectionStateChanged(int), Constant Field Values

LISTEN_DATA_ACTIVITY

public static final int LISTEN_DATA_ACTIVITY
Listen for changes to the direction of data traffic on the data connection (cellular). Example: The status bar uses this to display the appropriate data-traffic icon.

See Also:
onDataActivity(int), Constant Field Values

callback

IPhoneStateListener callback
The callback methods need to be called on the handler thread where this object was created. If the binder did that for us it'd be nice.


mHandler

Handler mHandler
Constructor Detail

PhoneStateListener

public PhoneStateListener()
Method Detail

onServiceStateChanged

public void onServiceStateChanged(ServiceState serviceState)
Callback invoked when device service state changes.

See Also:
ServiceState.STATE_EMERGENCY_ONLY, ServiceState.STATE_IN_SERVICE, ServiceState.STATE_OUT_OF_SERVICE, ServiceState.STATE_POWER_OFF

onSignalStrengthChanged

public void onSignalStrengthChanged(int asu)
Callback invoked when network signal strength changes.

See Also:
ServiceState.STATE_EMERGENCY_ONLY, ServiceState.STATE_IN_SERVICE, ServiceState.STATE_OUT_OF_SERVICE, ServiceState.STATE_POWER_OFF

onMessageWaitingIndicatorChanged

public void onMessageWaitingIndicatorChanged(boolean mwi)
Callback invoked when the message-waiting indicator changes.


onCallForwardingIndicatorChanged

public void onCallForwardingIndicatorChanged(boolean cfi)
Callback invoked when the call-forwarding indicator changes.


onCellLocationChanged

public void onCellLocationChanged(CellLocation location)
Callback invoked when device cell location changes.


onCallStateChanged

public void onCallStateChanged(int state,
                               String incomingNumber)
Callback invoked when device call state changes.

See Also:
TelephonyManager.CALL_STATE_IDLE, TelephonyManager.CALL_STATE_RINGING, TelephonyManager.CALL_STATE_OFFHOOK

onDataConnectionStateChanged

public void onDataConnectionStateChanged(int state)
Callback invoked when connection state changes.

See Also:
TelephonyManager.DATA_DISCONNECTED, TelephonyManager.DATA_CONNECTING, TelephonyManager.DATA_CONNECTED, TelephonyManager.DATA_SUSPENDED

onDataActivity

public void onDataActivity(int direction)
Callback invoked when data activity state changes.

See Also:
TelephonyManager.DATA_ACTIVITY_NONE, TelephonyManager.DATA_ACTIVITY_IN, TelephonyManager.DATA_ACTIVITY_OUT, TelephonyManager.DATA_ACTIVITY_INOUT

Build 1.0_r1(from source)

Please submit a feedback, bug or feature