本文整理匯總了Java中android.net.NetworkInfo.isFailover方法的典型用法代碼示例。如果您正苦於以下問題:Java NetworkInfo.isFailover方法的具體用法?Java NetworkInfo.isFailover怎麽用?Java NetworkInfo.isFailover使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.net.NetworkInfo
的用法示例。
在下文中一共展示了NetworkInfo.isFailover方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateNetworkState
import android.net.NetworkInfo; //導入方法依賴的package包/類
private void updateNetworkState(NetworkInfo info) {
boolean isConnected = mIsConnected;
boolean isFailover = mIsFailover;
boolean isCellularConnection = mIsCellularConnection;
boolean isRoaming = mIsRoaming;
boolean isAtLeast3G = mIsAtLeast3G;
if (null != info) {
mIsRoaming = info.isRoaming();
mIsFailover = info.isFailover();
mIsConnected = info.isConnected();
updateNetworkType(info.getType(), info.getSubtype());
} else {
mIsRoaming = false;
mIsFailover = false;
mIsConnected = false;
updateNetworkType(-1, -1);
}
mStateChanged = (mStateChanged || isConnected != mIsConnected
|| isFailover != mIsFailover
|| isCellularConnection != mIsCellularConnection
|| isRoaming != mIsRoaming || isAtLeast3G != mIsAtLeast3G);
if (Constants.LOGVV) {
if (mStateChanged) {
Log.v(LOG_TAG, "Network state changed: ");
Log.v(LOG_TAG, "Starting State: " +
(isConnected ? "Connected " : "Not Connected ") +
(isCellularConnection ? "Cellular " : "WiFi ") +
(isRoaming ? "Roaming " : "Local ") +
(isAtLeast3G ? "3G+ " : "<3G "));
Log.v(LOG_TAG, "Ending State: " +
(mIsConnected ? "Connected " : "Not Connected ") +
(mIsCellularConnection ? "Cellular " : "WiFi ") +
(mIsRoaming ? "Roaming " : "Local ") +
(mIsAtLeast3G ? "3G+ " : "<3G "));
if (isServiceRunning()) {
if (mIsRoaming) {
mStatus = STATUS_WAITING_FOR_NETWORK;
mControl = CONTROL_PAUSED;
} else if (mIsCellularConnection) {
DownloadsDB db = DownloadsDB.getDB(this);
int flags = db.getFlags();
if (0 == (flags & FLAGS_DOWNLOAD_OVER_CELLULAR)) {
mStatus = STATUS_QUEUED_FOR_WIFI;
mControl = CONTROL_PAUSED;
}
}
}
}
}
}