android.telephony.DataStateIntentReceiver
A IntentReceiver implementation that provides data connection state
over phone.
There are two Intents you can register and listen for: the
data connection state, and data activity state.
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
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
Public Constructors
public
DataStateIntentReceiver()
default constructor
public
DataStateIntentReceiver(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
DataActivityState
getActivityState()
getActivityState
Returns
- Phone.DataActivityState enum.
throws RuntimeException if client has not called notifyActivity(int)
public
DataState
getConnectionState()
getConnectionState
Returns
- Phone.DataState enum.
throws RuntimeException if client has not called
notifyConnectionState(int)
public
boolean
getNotifyActivityState()
Check if registere for data activity state notification
public
boolean
getNotifyConnectionState()
Check if registere for data connection state notification
public
void
notifyActivity(int eventWhat)
Call this if you want to be notified of data activity states.
Parameters
| eventWhat
| the callback event what code.
|
public
void
notifyConnectionState(int eventWhat)
Call this if you want to be notified of data connection states.
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