English | Site Directory

Android - An Open Handset Alliance Project

android.telephony
public class

android.telephony.DataStateIntentReceiver

java.lang.Object
android.content.IntentReceiver
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

          DataStateIntentReceiver()
default constructor
          DataStateIntentReceiver(Context context, Handler target)
Commonly use constructor

Public Methods

        DataActivityState  getActivityState()
getActivityState
        DataState  getConnectionState()
getConnectionState
        boolean  getNotifyActivityState()
Check if registere for data activity state notification
        boolean  getNotifyConnectionState()
Check if registere for data connection state notification
        void  notifyActivity(int eventWhat)
Call this if you want to be notified of data activity states.
        void  notifyConnectionState(int eventWhat)
Call this if you want to be notified of data connection states.
        void  onReceiveIntent(Context context, Intent intent)
This method is called when the IntentReceiver is receiving an Intent broadcast.
        void  registerIntent()
Register to be run in caller thread with intent filter
        void  setContext(Context c)
Set the application environment of caller
        void  setTarget(Handler h)
Set the message post and callback handler provided by caller
        void  unregisterIntent()
Unregister from caller thread
Methods inherited from class android.content.IntentReceiver
Methods inherited from class java.lang.Object

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

Returns

  • true for registered

public boolean getNotifyConnectionState()

Check if registere for data connection state notification

Returns

  • true for registered

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
Build m5-rc15i - 10 Jun 2008 13:54