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


Java ConnectivityManager.TYPE_ETHERNET属性代码示例

本文整理汇总了Java中android.net.ConnectivityManager.TYPE_ETHERNET属性的典型用法代码示例。如果您正苦于以下问题:Java ConnectivityManager.TYPE_ETHERNET属性的具体用法?Java ConnectivityManager.TYPE_ETHERNET怎么用?Java ConnectivityManager.TYPE_ETHERNET使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.net.ConnectivityManager的用法示例。


在下文中一共展示了ConnectivityManager.TYPE_ETHERNET属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    long time = System.currentTimeMillis();
    if (time - oldTime < 1000) {
        return;
    }
    oldTime = time;
    ConnectivityManager mConnectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netInfo = mConnectivityManager.getActiveNetworkInfo();
    if (netInfo != null && netInfo.isAvailable()) {
        switch (netInfo.getType()) {
            case ConnectivityManager.TYPE_MOBILE:
                netType = 0;
                netName = netInfo.getSubtypeName();
                break;
            case ConnectivityManager.TYPE_WIFI:
                netType = 1;
                netName = netInfo.getTypeName();
                break;
            case ConnectivityManager.TYPE_ETHERNET:
                netType = 2;
                netName = netInfo.getTypeName();
                break;
            default:
                netType = 3;
                netName = "OtherNetWork";
                break;
        }
    } else {
        netType = -1;
        netName = "NoNetWork";
    }
    if (onNetListener != null) {
        onNetListener.onNetStatus(netType, netName);
    }
}
 
开发者ID:abook23,项目名称:godlibrary,代码行数:38,代码来源:NetBroadcastReceiver.java

示例2: connectionTypeString

private String connectionTypeString(int connectionType) {
    switch (connectionType) {
        case ConnectivityManager.TYPE_WIFI:
            return "Wifi";
        case ConnectivityManager.TYPE_BLUETOOTH:
            return "Bluetooth";
        case ConnectivityManager.TYPE_ETHERNET:
            return "Ethernet";
        case ConnectivityManager.TYPE_MOBILE:
            return "Mobile";
        case ConnectivityManager.TYPE_MOBILE_DUN:
            return "Mobile dun";
        case ConnectivityManager.TYPE_VPN:
            return "VPN";
        default:
            return "Unknown";
    }
}
 
开发者ID:wkmeijer,项目名称:CS4160-trustchain-android,代码行数:18,代码来源:PeerListAdapter.java

示例3: onReceive

public void onReceive(Context context, Intent intent) {
    boolean noConnectivity = intent.getBooleanExtra(
            ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
    String reason = intent
            .getStringExtra(ConnectivityManager.EXTRA_REASON);
    boolean isFailover = intent.getBooleanExtra(
            ConnectivityManager.EXTRA_IS_FAILOVER, false);
    NetworkInfo currentNetworkInfo = (NetworkInfo) intent
            .getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
    NetworkInfo otherNetworkInfo = (NetworkInfo) intent
            .getParcelableExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO);

    if (currentNetworkInfo.isConnected()
            && currentNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
        tip.setText("Connected to the Wireless Network");
    } else if (currentNetworkInfo.isConnected()
            && currentNetworkInfo.getType() == ConnectivityManager.TYPE_ETHERNET) {
        tip.setText("Connected to the Wired Network");
    }
}
 
开发者ID:Evan-Galvin,项目名称:FreeStreams-TVLauncher,代码行数:20,代码来源:Ethernet.java

示例4: getConnectivityStatus

/**
 * Uses the provided context to determine the current connectivity status.
 *
 * @param context A context used to retrieve connection information from
 * @return A non-null value defined in {@link Status}
 */
public static Status getConnectivityStatus(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);

    NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
    switch (activeNetwork != null ? activeNetwork.getType() : CONST_NO_NETWORK) {
        case ConnectivityManager.TYPE_WIFI:
        case ConnectivityManager.TYPE_ETHERNET:
            return Status.WIFI;
        case ConnectivityManager.TYPE_MOBILE:
        case ConnectivityManager.TYPE_BLUETOOTH:
        case ConnectivityManager.TYPE_WIMAX:
            return Status.MOBILE;
        default:
            return Status.NONE;
    }
}
 
开发者ID:ccrama,项目名称:Slide-RSS,代码行数:23,代码来源:NetworkUtil.java

示例5: isLocalNetworkConnected

public static boolean isLocalNetworkConnected(Context context) {
    // Check network status
    boolean networkEnabled = false;
    ConnectivityManager connectivity = (ConnectivityManager)(context.getSystemService(Context.CONNECTIVITY_SERVICE));
    if (connectivity != null) {
        NetworkInfo networkInfo = connectivity.getActiveNetworkInfo();
        if (networkInfo != null && networkInfo.isConnected() &&
                (networkInfo.getType() == ConnectivityManager.TYPE_WIFI || networkInfo.getType() == ConnectivityManager.TYPE_ETHERNET)) {
            networkEnabled = true;
        }
    }

    return networkEnabled;
}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:14,代码来源:ArchosUtils.java

示例6: adjustThreadCount

void adjustThreadCount(NetworkInfo info) {
    if (info == null || !info.isConnectedOrConnecting()) {
        setThreadCount(DEFAULT_THREAD_COUNT);
        return;
    }
    switch (info.getType()) {
        case ConnectivityManager.TYPE_WIFI:
        case ConnectivityManager.TYPE_WIMAX:
        case ConnectivityManager.TYPE_ETHERNET:
            setThreadCount(4);
            break;
        case ConnectivityManager.TYPE_MOBILE:
            switch (info.getSubtype()) {
                case TelephonyManager.NETWORK_TYPE_LTE:  // 4G
                case TelephonyManager.NETWORK_TYPE_HSPAP:
                case TelephonyManager.NETWORK_TYPE_EHRPD:
                    setThreadCount(3);
                    break;
                case TelephonyManager.NETWORK_TYPE_UMTS: // 3G
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_EVDO_B:
                    setThreadCount(2);
                    break;
                case TelephonyManager.NETWORK_TYPE_GPRS: // 2G
                case TelephonyManager.NETWORK_TYPE_EDGE:
                    setThreadCount(1);
                    break;
                default:
                    setThreadCount(DEFAULT_THREAD_COUNT);
            }
            break;
        default:
            setThreadCount(DEFAULT_THREAD_COUNT);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:37,代码来源:ANExecutor.java

示例7: getNetWorkType

/**
 * 网络
 */
public static int getNetWorkType(Context context) {
    int netType;
    ConnectivityManager mConnectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netInfo = mConnectivityManager.getActiveNetworkInfo();
    if (netInfo != null && netInfo.isAvailable()) {
        switch (netInfo.getType()) {
            case ConnectivityManager.TYPE_MOBILE:
                netType = 0;
                break;
            case ConnectivityManager.TYPE_WIFI:
                netType = 1;

                break;
            case ConnectivityManager.TYPE_ETHERNET:
                netType = 2;

                break;
            default:
                netType = 3;

                break;
        }
    } else {
        netType = -1;
    }
    return netType;
}
 
开发者ID:abook23,项目名称:godlibrary,代码行数:31,代码来源:AndroidUtils.java

示例8: isNetworkWiFi

/**
 * Check if there is any connectivity to a WiFi network
 *
 * @param ctx the application Context
 * @return true if the device is connected to WiFi
 */
public static boolean isNetworkWiFi(final Context ctx) {
    final NetworkInfo info = getActiveNetworkInfo(ctx);

    return info != null && (info.getType() == ConnectivityManager.TYPE_WIFI
            || info.getType() == ConnectivityManager.TYPE_ETHERNET);

}
 
开发者ID:brandall76,项目名称:Saiy-PS,代码行数:13,代码来源:Network.java

示例9: checkNetworkType

static int checkNetworkType(Context context) {

        int netType = 0;
        //连接管理对象
        ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        //获取NetworkInfo对象
        @SuppressLint("MissingPermission") NetworkInfo networkInfo = manager.getActiveNetworkInfo();
        if (networkInfo == null)
            return netType;
        switch (networkInfo.getType()) {
            case ConnectivityManager.TYPE_WIFI:
            case ConnectivityManager.TYPE_WIMAX:
            case ConnectivityManager.TYPE_ETHERNET:
                return 1;

            case ConnectivityManager.TYPE_MOBILE:
                switch (networkInfo.getSubtype()) {
                    case TelephonyManager.NETWORK_TYPE_LTE:  // 4G
                    case TelephonyManager.NETWORK_TYPE_HSPAP:
                    case TelephonyManager.NETWORK_TYPE_EHRPD:
                        return 2;
                    case TelephonyManager.NETWORK_TYPE_UMTS: // 3G
                    case TelephonyManager.NETWORK_TYPE_CDMA:
                    case TelephonyManager.NETWORK_TYPE_EVDO_0:
                    case TelephonyManager.NETWORK_TYPE_EVDO_A:
                    case TelephonyManager.NETWORK_TYPE_EVDO_B:
                        return 3;

                    case TelephonyManager.NETWORK_TYPE_GPRS: // 2G
                    case TelephonyManager.NETWORK_TYPE_EDGE:
                        return 4;

                    default:
                        return netType;
                }

            default:

                return netType;
        }

    }
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:42,代码来源:AgentWebUtils.java

示例10: checkNetworkType

public static int checkNetworkType(Context context) {

        int netType = 0;
        //连接管理对象
        ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        //获取NetworkInfo对象
        NetworkInfo networkInfo = manager.getActiveNetworkInfo();
        if (networkInfo == null)
            return netType;
        switch (networkInfo.getType()) {
            case ConnectivityManager.TYPE_WIFI:
            case ConnectivityManager.TYPE_WIMAX:
            case ConnectivityManager.TYPE_ETHERNET:
                return 1;

            case ConnectivityManager.TYPE_MOBILE:
                switch (networkInfo.getSubtype()) {
                    case TelephonyManager.NETWORK_TYPE_LTE:  // 4G
                    case TelephonyManager.NETWORK_TYPE_HSPAP:
                    case TelephonyManager.NETWORK_TYPE_EHRPD:
                        return 2;
                    case TelephonyManager.NETWORK_TYPE_UMTS: // 3G
                    case TelephonyManager.NETWORK_TYPE_CDMA:
                    case TelephonyManager.NETWORK_TYPE_EVDO_0:
                    case TelephonyManager.NETWORK_TYPE_EVDO_A:
                    case TelephonyManager.NETWORK_TYPE_EVDO_B:
                        return 3;

                    case TelephonyManager.NETWORK_TYPE_GPRS: // 2G
                    case TelephonyManager.NETWORK_TYPE_EDGE:
                        return 4;

                    default:
                        return netType;
                }

            default:

                return netType;
        }

    }
 
开发者ID:Justson,项目名称:AgentWebX5,代码行数:42,代码来源:AgentWebX5Utils.java

示例11: isEthernetByType

/**
 * 判断当前网络的类型是否是ETHERNET
 *
 * @param context 上下文
 * @return 当前网络的类型是否是ETHERNET。false:当前没有网络连接或者网络类型不是ETHERNET
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public static boolean isEthernetByType(Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) {
        return false;
    }
    else {
        return getCurrentNetworkType(context) ==
                ConnectivityManager.TYPE_ETHERNET;
    }
}
 
开发者ID:liying2008,项目名称:Simpler,代码行数:16,代码来源:NetWorkUtils.java

示例12: getNetworkTypeName

private static String getNetworkTypeName(int type) {
	switch (type) {
	case ConnectivityManager.TYPE_MOBILE:
		return "MOBILE";
	case ConnectivityManager.TYPE_WIFI:
		return "WIFI";
	case ConnectivityManager.TYPE_MOBILE_MMS:
		return "MOBILE_MMS";
	case ConnectivityManager.TYPE_MOBILE_SUPL:
		return "MOBILE_SUPL";
	case ConnectivityManager.TYPE_MOBILE_DUN:
		return "MOBILE_DUN";
	case ConnectivityManager.TYPE_MOBILE_HIPRI:
		return "MOBILE_HIPRI";
	case ConnectivityManager.TYPE_WIMAX:
		return "WIMAX";
	case ConnectivityManager.TYPE_BLUETOOTH:
		return "BLUETOOTH";
	case ConnectivityManager.TYPE_DUMMY:
		return "DUMMY";
	case ConnectivityManager.TYPE_ETHERNET:
		return "ETHERNET";
	case 10: // ConnectivityManager.TYPE_MOBILE_FOTA:
		return "MOBILE_FOTA";
	case 11: // ConnectivityManager.TYPE_MOBILE_IMS:
		return "MOBILE_IMS";
	case 12: // ConnectivityManager.TYPE_MOBILE_CBS:
		return "MOBILE_CBS";
	case 13: // ConnectivityManager.TYPE_WIFI_P2P:
		return "WIFI_P2P";
	default:
		return Integer.toString(type);
	}
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:34,代码来源:NetworkUtil.java

示例13: getHdByNetwork

private
@Quality
int getHdByNetwork() {
    ConnectivityManager cm = (ConnectivityManager) mContext.get().getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = cm.getActiveNetworkInfo();
    if (networkInfo == null || !networkInfo.isConnected()) {
        LogUtil.e(TAG, "No networking found");
        makeToast();
        return VideoInfoImpl.HD_UNSPECIFIED;
    }
    switch (networkInfo.getType()) {
        case ConnectivityManager.TYPE_WIFI:
        case ConnectivityManager.TYPE_WIMAX:
        case ConnectivityManager.TYPE_ETHERNET:
            return HD_HIGH;
        case ConnectivityManager.TYPE_MOBILE:
            switch (networkInfo.getSubtype()) {
                case TelephonyManager.NETWORK_TYPE_LTE:
                case TelephonyManager.NETWORK_TYPE_HSPAP:
                case TelephonyManager.NETWORK_TYPE_EHRPD:
                    return HD_STANDARD;
                case TelephonyManager.NETWORK_TYPE_UMTS: // 3G
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_EVDO_B:
                    return HD_MEDIUM;
                case TelephonyManager.NETWORK_TYPE_GPRS: // 2G
                case TelephonyManager.NETWORK_TYPE_EDGE:
                    return HD_LOW;
                default:
                    return HD_LOW;
            }
        default:
            return HD_LOW;
    }
}
 
开发者ID:TedaLIEz,项目名称:ParsingPlayer,代码行数:37,代码来源:ConcatSourceProvider.java

示例14: updateNetworkType

/**
 * Updates the network type based upon the type and subtype returned from
 * the connectivity manager. Subtype is only used for cellular signals.
 *
 * @param type
 * @param subType
 */
private void updateNetworkType(int type, int subType) {
    switch (type) {
        case ConnectivityManager.TYPE_WIFI:
        case ConnectivityManager.TYPE_ETHERNET:
        case ConnectivityManager.TYPE_BLUETOOTH:
            mIsCellularConnection = false;
            mIsAtLeast3G = false;
            mIsAtLeast4G = false;
            break;
        case ConnectivityManager.TYPE_WIMAX:
            mIsCellularConnection = true;
            mIsAtLeast3G = true;
            mIsAtLeast4G = true;
            break;
        case ConnectivityManager.TYPE_MOBILE:
            mIsCellularConnection = true;
            switch (subType) {
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_EDGE:
                case TelephonyManager.NETWORK_TYPE_GPRS:
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    mIsAtLeast3G = false;
                    mIsAtLeast4G = false;
                    break;
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                case TelephonyManager.NETWORK_TYPE_HSPA:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_UMTS:
                    mIsAtLeast3G = true;
                    mIsAtLeast4G = false;
                    break;
                case TelephonyManager.NETWORK_TYPE_LTE: // 4G
                case TelephonyManager.NETWORK_TYPE_EHRPD: // 3G ++ interop
                                                          // with 4G
                case TelephonyManager.NETWORK_TYPE_HSPAP: // 3G ++ but
                                                          // marketed as
                                                          // 4G
                    mIsAtLeast3G = true;
                    mIsAtLeast4G = true;
                    break;
                default:
                    mIsCellularConnection = false;
                    mIsAtLeast3G = false;
                    mIsAtLeast4G = false;
            }
    }
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:57,代码来源:DownloaderService.java

示例15: updateNetworkType

/**
 * Updates the network type based upon the type and subtype returned from
 * the connectivity manager. Subtype is only used for cellular signals.
 * 
 * @param type
 * @param subType
 */
private void updateNetworkType(int type, int subType) {
    switch (type) {
        case ConnectivityManager.TYPE_WIFI:
        case ConnectivityManager.TYPE_ETHERNET:
        case ConnectivityManager.TYPE_BLUETOOTH:
            mIsCellularConnection = false;
            mIsAtLeast3G = false;
            mIsAtLeast4G = false;
            break;
        case ConnectivityManager.TYPE_WIMAX:
            mIsCellularConnection = true;
            mIsAtLeast3G = true;
            mIsAtLeast4G = true;
            break;
        case ConnectivityManager.TYPE_MOBILE:
            mIsCellularConnection = true;
            switch (subType) {
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_EDGE:
                case TelephonyManager.NETWORK_TYPE_GPRS:
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    mIsAtLeast3G = false;
                    mIsAtLeast4G = false;
                    break;
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                case TelephonyManager.NETWORK_TYPE_HSPA:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_UMTS:
                    mIsAtLeast3G = true;
                    mIsAtLeast4G = false;
                    break;
                case TelephonyManager.NETWORK_TYPE_LTE: // 4G
                case TelephonyManager.NETWORK_TYPE_EHRPD: // 3G ++ interop
                                                          // with 4G
                case TelephonyManager.NETWORK_TYPE_HSPAP: // 3G ++ but
                                                          // marketed as
                                                          // 4G
                    mIsAtLeast3G = true;
                    mIsAtLeast4G = true;
                    break;
                default:
                    mIsCellularConnection = false;
                    mIsAtLeast3G = false;
                    mIsAtLeast4G = false;
            }
    }
}
 
开发者ID:SlotNSlot,项目名称:SlotNSlot_Android,代码行数:57,代码来源:DownloaderService.java


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