Android
android.telephony
public class

android.telephony.PhoneStateListener

java.lang.Object
android.telephony.PhoneStateListener

Class used to listen for changes in the phone state, including the service state, signal strength, message waiting (voicemail) indicator, etc.

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().

Summary

Constants

      Value  
int  LISTEN_CALL_FORWARDING_INDICATOR  Listen for changes to the call forwarding indicator.  0x00000008 
int  LISTEN_CALL_STATE  Listen for changes to the call state.  32  0x00000020 
int  LISTEN_CELL_LOCATION  Listen for changes to the cell location. You probably don't want this method. You probably want to use the LocationManager.   16  0x00000010 
int  LISTEN_DATA_ACTIVITY  Listen for changes to the direction of data traffic.  128  0x00000080 
int  LISTEN_DATA_CONNECTION_STATE  Listen for changes to the data connection state. This is only for the phone radio, e.g. GPRS, EDGE, etc connection.   64  0x00000040 
int  LISTEN_MESSAGE_WAITING_INDICATOR  Listen for changes to the message waiting indicator.  0x00000004 
int  LISTEN_NONE  Stop listening for updates.  0x00000000 
int  LISTEN_SERVICE_STATE  Listen for changes to the service state.  0x00000001 
int  LISTEN_SIGNAL_STRENGTH  Listen for changes to the signal strength.  0x00000002 

Public Constructors

            PhoneStateListener()

Public Methods

          void  onCallForwardingIndicatorChanged(boolean cfi)
          void  onCallStateChanged(int state, String incomingNumber)
          void  onCellLocationChanged(CellLocation location)
          void  onDataActivity(int direction)
          void  onDataConnectionStateChanged(int state)
          void  onMessageWaitingIndicatorChanged(boolean mwi)
          void  onServiceStateChanged(ServiceState serviceState)
          void  onSignalStrengthChanged(int asu)
Methods inherited from class java.lang.Object

Details

Constants

public static final int LISTEN_CALL_FORWARDING_INDICATOR

Listen for changes to the call forwarding indicator.
Constant Value: 8 (0x00000008)

public static final int LISTEN_CALL_STATE

Listen for changes to the call state.
Constant Value: 32 (0x00000020)

public static final int LISTEN_CELL_LOCATION

Listen for changes to the cell location. You probably don't want this method. You probably want to use the LocationManager.

This requires the ACCESS_COARSE_LOCATION permission.

Constant Value: 16 (0x00000010)

public static final int LISTEN_DATA_ACTIVITY

Listen for changes to the direction of data traffic. This is what the status bar uses to display its icon that blinks when there is data traffic on the cell connection.
Constant Value: 128 (0x00000080)

public static final int LISTEN_DATA_CONNECTION_STATE

Listen for changes to the data connection state. This is only for the phone radio, e.g. GPRS, EDGE, etc connection.

Pass this to TelephonyManager.listen() if you want to receive notifications via the onDataConnectionStateChanged(int) method.

Constant Value: 64 (0x00000040)

public static final int LISTEN_MESSAGE_WAITING_INDICATOR

Listen for changes to the message waiting indicator.

This is what the status bar uses to turn on the icon when there is a voicemail waiting.

Constant Value: 4 (0x00000004)

public static final int LISTEN_NONE

Stop listening for updates. Pass to TelephonyManager.listen().
Constant Value: 0 (0x00000000)

public static final int LISTEN_SERVICE_STATE

Listen for changes to the service state.
Constant Value: 1 (0x00000001)

public static final int LISTEN_SIGNAL_STRENGTH

Listen for changes to the signal strength.

This is what the status bar uses to control the icon.

Constant Value: 2 (0x00000002)

Public Constructors

public PhoneStateListener()

Public Methods

public void onCallForwardingIndicatorChanged(boolean cfi)

public void onCallStateChanged(int state, String incomingNumber)

public void onCellLocationChanged(CellLocation location)

public void onDataActivity(int direction)

public void onDataConnectionStateChanged(int state)

public void onMessageWaitingIndicatorChanged(boolean mwi)

public void onServiceStateChanged(ServiceState serviceState)

public void onSignalStrengthChanged(int asu)

Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48