frameworks/base/core/java/android/net ConnectivityManager.java:裡面有定義各類連線類型: TYPE_WIFI, TYPE_MOBILE_MMS, TYPE_BLUETOOTH, TYPE_DUMMY, TYPE_ETHERNET, TYPE_PROXY,
跟 "目前網路狀態" 有關的,好像是...
/**
* Returns details about the currently active default data network. When
* connected, this network is the default route for outgoing connections.
* You should always check {@link NetworkInfo#isConnected()} before initiating
* network traffic. This may return {@code null} when there is no default
* network.
* This method requires the caller to hold the permission
* {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
*
* @return a {@link NetworkInfo} object for the current default network
* or {@code null} if no default network is currently active
*/
public NetworkInfo getActiveNetworkInfo() {
try {
return mService.getActiveNetworkInfo();
} catch (RemoteException e) {
return null;
}
}
/**
* Returns a {@link Network} object corresponding to the currently active
* default data network. In the event that the current active default data
* network disconnects, the returned {@code Network} object will no longer
* be usable. This will return {@code null} when there is no default
* network.
*
This method requires the caller to hold the permission
* {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
*
* @return a {@link Network} object for the current default network or
* {@code null} if no default network is currently active
*/
public Network getActiveNetwork() {
try {
return mService.getActiveNetwork();
} catch (RemoteException e) {
return null;
}
}
還有一個,好像是要使用網路之前,要call 的...另外在 frameworks/opt/net 下也有.. ethernet, ims, voip, wifi 四個 categories..
沒有留言:
張貼留言