android.telephony
public
final
class
android.telephony.PhoneStateIntentReceiver
A IntentReceiver implementation that provides phone state and operation
information.
There are five Intents you can register and listen for: the
service state, phone call state, signal strength,
message waiting indicator, and call forwarding indicator.
For each of these intents you have to register with corresponding notify
function before calling corresponding get function to access values.
You can use unregisterIntent and registerIntent to stop and resume listening.
Summary
Constants
Public Constructors
Public Methods
abortBroadcast,
clearAbortBroadcast,
getAbortBroadcast,
getDebugUnregister,
getResultCode,
getResultData,
getResultExtras,
onReceiveIntent,
setDebugUnregister,
setResult,
setResultCode,
setResultData,
setResultExtras
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Constants
public
static
final
String
INTENT_KEY_ASU
public
static
final
String
INTENT_KEY_CFI
public
static
final
String
INTENT_KEY_MWI
Public Constructors
public
PhoneStateIntentReceiver()
default constructor
public
PhoneStateIntentReceiver(Context context, Handler target)
Commonly use constructor
Parameters
| context
| the application environment of caller |
| target
| the message post and callback handler provided by caller
|
Public Methods
public
boolean
getCallForwardingIndicator()
Return current call forwarding indicator state.
Returns
- true if there are call forwarding.
Throws RuntimeException if client has not called
notifyCallForwardingIndicator()
public
boolean
getMessageWaitingIndicator()
Return current message waiting indicator state.
Returns
- true if there are messages waiting.
Throws RuntimeException if client has not called
notifyMessageWaitingIndicator()
public
boolean
getNotifyCallForwardingIndicator()
Check if registere for call forwarding notification
public
boolean
getNotifyMessageWaitingIndicator()
Check if registere for message waiting notification
public
boolean
getNotifyPhoneCallState()
Check if registere for phone call state notification
public
boolean
getNotifyServiceState()
Check if registere for service state notification
public
boolean
getNotifySignalStrength()
Check if registere for signal strength notification
public
State
getPhoneState()
Returns current phone state
Returns
- Phone.State enum. Phone.IDLE if not yet updated.
Throws RuntimeException if client has not called notifyPhoneCallState()
public
ServiceState
getServiceState()
Returns current service state
Returns
- ServiceState object, "out of service" info if not yet updated.
Throws RuntimeException if client has not called notifyServiceState()
public
int
getSignalStrength()
Returns current signal strength in "asu", ranging from 0-31
or -1 if unknown
For GSM, dBm = -113 + 2*asu
0 means "-113 dBm or less"
31 means "-51 dBm or greater"
Returns
- signal strength in asu, -1 if not yet updated
Throws RuntimeException if client has not called notifySignalStrength()
public
int
getSignalStrengthDbm()
Return current signal strength in "dBm", ranging from -113 - -51dBm
or -1 if unknown
Returns
- signal strength in dBm, -1 if not yet updated
Throws RuntimeException if client has not called notifySignalStrength()
public
void
notifyCallForwardingIndicator(int eventWhat)
Call this if you want to be notified of call forwarding states.
Parameters
| eventWhat
| the callback event what code.
|
public
void
notifyMessageWaitingIndicator(int eventWhat)
Call this if you want to be notified of message waiting states.
Parameters
| eventWhat
| the callback event what code.
|
public
void
notifyPhoneCallState(int eventWhat)
Call this if you want to be notified of phone call states.
Parameters
| eventWhat
| the callback event what code.
|
public
void
notifyServiceState(int eventWhat)
Call this if you want to be notified of phone service states.
Parameters
| eventWhat
| the callback event what code.
|
public
void
notifySignalStrength(int eventWhat)
Call this if you want to be notified of radio signal strength.
Parameters
| eventWhat
| the callback event what code.
|
public
void
onReceiveIntent(Context context, Intent intent)
This method is called when the IntentReceiver is receiving an Intent
broadcast. During this time you can use the other methods on
IntentReceiver to view/modify the current result values. The function
is normally called from the main thread of its process, so you should
never perform long-running operations in it (there is a timeout of
10 seconds that the system allows before considering the receiver to
be blocked and a candidate to be killed). You cannot launch a popup dialog
in your implementation of onReceiveIntent().
If this IntentReceiver was launched through a <receiver> tag,
then the object is no longer alive after returning from this
function. This means you should not perform any operations that
return a result to you asynchronously -- in particular, for interacting
with services, you should use
startService(Intent, Bundle) instead of
bindService(Intent, ServiceConnection, int).
Parameters
| context
| The Context in which the receiver is running. |
| intent
| The Intent being received.
|
public
void
registerIntent()
Register to be run in caller thread with intent filter
public
void
setContext(Context c)
Set the application environment of caller
Parameters
| c
| the application environment of caller
|
public
void
setTarget(Handler h)
Set the message post and callback handler provided by caller
Parameters
| h
| the message post and callback handler provided by caller
|
public
void
unregisterIntent()
Unregister from caller thread