当前位置: 首页>>代码示例>>Java>>正文


Java NetworkInfo.isFailover方法代码示例

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

        }
    }
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:53,代码来源:DownloaderService.java


注:本文中的android.net.NetworkInfo.isFailover方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。