本文整理汇总了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;
}
}
}
}
}
}