| | |
| | | package com.hdl.sdk.common.utils;
|
| | |
|
| | | import android.content.Context;
|
| | | import android.net.wifi.WifiInfo;
|
| | | import android.net.wifi.WifiManager;
|
| | | //import android.content.Context;
|
| | | //import android.net.wifi.WifiInfo;
|
| | | //import android.net.wifi.WifiManager;
|
| | |
|
| | | import java.net.InetAddress;
|
| | | import java.net.InterfaceAddress;
|
| | |
| | | * @return 广播地址
|
| | | */
|
| | | public static String getBroadcastAddress() {
|
| | | // try {
|
| | | // for (Enumeration<NetworkInterface> niEnum = NetworkInterface.getNetworkInterfaces();
|
| | | // niEnum.hasMoreElements(); ) {
|
| | | // NetworkInterface ni = niEnum.nextElement();
|
| | | // if (!ni.isLoopback()) {
|
| | | // for (InterfaceAddress interfaceAddress : ni.getInterfaceAddresses()) {
|
| | | // if (interfaceAddress.getBroadcast() != null) {
|
| | | // return interfaceAddress.getBroadcast().toString().substring(1);
|
| | | // }
|
| | | // }
|
| | | // }
|
| | | // }
|
| | | // } catch (SocketException e) {
|
| | | // e.printStackTrace();
|
| | | // }
|
| | | return "255.255.255.255";
|
| | | }
|
| | |
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | public static String getIP(Context application) {
|
| | | /*public static String getIP(Context application) {
|
| | | WifiManager wifiManager = (WifiManager) application.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
| | | if (!wifiManager.isWifiEnabled()) {
|
| | | try {
|
| | |
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | */
|
| | |
|
| | | private static String intToIp(int i) {
|
| | |
|