|
WIMM Labs |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.wimm.framework.service.NetworkService
public class NetworkService
The NetworkService
class provides an interface for requesting a network connection.
Start by registering for the ACTION_NETWORK_AVAILABLE
and ACTION_NETWORK_TAKEDOWN
intents and calling requestNetworkConnection()
. If the service is able to bring up a network connection
it broadcasts the ACTION_NETWORK_AVAILABLE
intent. If the network connection can not be brought up,
the service will broadcast the ACTION_NETWORK_FAILURE
intent with an error code.
Once the network connection is established, the service sends a ACTION_NETWORK_TAKEDOWN
intent at
regular intervals. On receiving a ACTION_NETWORK_TAKEDOWN
, call postponeNetworkTakedown()
if the network connection is still needed.
The service will take down the network connection if no listeners call postponeNetworkTakedown()
.
Note: postponeNetworkTakedown()
requests may not be honored in all cases.
This depends on the length of time the connection has been up and battery/charging state.
Use of this class requires the "com.wimm.permission.NETWORK"
permission.
Refer to WIMM Developer's Guide on network HOWTO guide for more information about WIMM Network connection.
Nested Class Summary | |
---|---|
static class |
NetworkService.Error
Values returned in the extra EXTRA_ERROR . |
Field Summary | |
---|---|
static String |
ACTION_NETWORK_AVAILABLE
Intent broadcast when the network connection is available. |
static String |
ACTION_NETWORK_FAILURE
Intent broadcast when a network connection request fails. |
static String |
ACTION_NETWORK_TAKEDOWN
Intent broadcast when the system is ready to close the network connection. |
static String |
EXTRA_ERROR
An int extra in ACTION_NETWORK_FAILURE containing the failure reason. |
Constructor Summary | |
---|---|
NetworkService(Context context)
Instantiates a new network service. |
Method Summary | |
---|---|
boolean |
isNetworkAvailable()
Checks if the network connection is available. |
void |
postponeNetworkTakedown()
Request that the network connection remain open. |
void |
requestNetworkConnection()
Requests a network connection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ACTION_NETWORK_AVAILABLE
This is a sticky broadcast.
requestNetworkConnection()
,
Constant Field Valuespublic static final String ACTION_NETWORK_FAILURE
May include the following extras:
EXTRA_ERROR
containing the failure reason.
requestNetworkConnection()
,
Constant Field Valuespublic static final String ACTION_NETWORK_TAKEDOWN
postponeNetworkTakedown()
,
Constant Field Valuespublic static final String EXTRA_ERROR
ACTION_NETWORK_FAILURE
containing the failure reason.
Possible values are listed in NetworkService.Error
.
Constructor Detail |
---|
public NetworkService(Context context)
context
- The Context
.Method Detail |
---|
public void requestNetworkConnection()
public void postponeNetworkTakedown()
ACTION_NETWORK_TAKEDOWN
.
public boolean isNetworkAvailable()
true
if the network connection is available.
|
WIMM Labs |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |