android.text.format.Formatter.formatIpAddress()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(136)

本文整理了Java中android.text.format.Formatter.formatIpAddress()方法的一些代码示例,展示了Formatter.formatIpAddress()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Formatter.formatIpAddress()方法的具体详情如下:
包路径:android.text.format.Formatter
类名称:Formatter
方法名:formatIpAddress

Formatter.formatIpAddress介绍

暂无

代码示例

代码示例来源:origin: ac-pm/Inspeckage

String ssid = wi.getSSID();
li.add(new FingerprintItem("Wi-Fi", "SSID", ssid.substring(1, ssid.length() - 1), ssid.substring(1, ssid.length() - 1), false));
String ipAddress = Formatter.formatIpAddress(wi.getIpAddress());
li.add(new FingerprintItem("Wi-Fi", "IP", ipAddress, ipAddress, false));

代码示例来源:origin: piotrpolak/android-http-server

InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
  return Formatter.formatIpAddress(inetAddress.hashCode());

代码示例来源:origin: couchbaselabs/mini-hacks

/** Get local IP to display in a TextView on the P2P tab */
public String getLocalIpAddress() {
  WifiManager wm = (WifiManager) getSystemService(WIFI_SERVICE);
  return Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
}

代码示例来源:origin: ShawnBaker/RPiCameraViewer

public static String getLocalIpAddress()
{
  String address = "";
  WifiManager manager = (WifiManager)App.getContext().getApplicationContext().getSystemService(Context.WIFI_SERVICE);
  if (manager.isWifiEnabled())
  {
    WifiInfo wifiInfo = manager.getConnectionInfo();
    if (wifiInfo != null)
    {
      NetworkInfo.DetailedState state = WifiInfo.getDetailedStateOf(wifiInfo.getSupplicantState());
      if (state == NetworkInfo.DetailedState.CONNECTED || state == NetworkInfo.DetailedState.OBTAINING_IPADDR)
      {
        int ip = wifiInfo.getIpAddress();
        address = Formatter.formatIpAddress(ip);
      }
    }
  }
  return address;
}

代码示例来源:origin: brarcher/protect-baby-monitor

final String ipAddress = Formatter.formatIpAddress(address);
addressText.setText(ipAddress);

代码示例来源:origin: termux/termux-api

@SuppressLint("HardwareIds")
  @Override
  public void writeJson(JsonWriter out) throws Exception {
    WifiManager manager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    WifiInfo info = manager.getConnectionInfo();
    out.beginObject();
    if (info == null) {
      out.name("API_ERROR").value("No current connection");
    } else {
      out.name("bssid").value(info.getBSSID());
      out.name("frequency_mhz").value(info.getFrequency());
      //noinspection deprecation - formatIpAddress is deprecated, but we only have a ipv4 address here:
      out.name("ip").value(Formatter.formatIpAddress(info.getIpAddress()));
      out.name("link_speed_mbps").value(info.getLinkSpeed());
      out.name("mac_address").value(info.getMacAddress());
      out.name("network_id").value(info.getNetworkId());
      out.name("rssi").value(info.getRssi());
      out.name("ssid").value(info.getSSID().replaceAll("\"", ""));
      out.name("ssid_hidden").value(info.getHiddenSSID());
      out.name("supplicant_state").value(info.getSupplicantState().toString());
    }
    out.endObject();
  }
});

相关文章