android连接wifi时获取广播地址代码
时间:2022-11-20 13:08:32
private InetAddress getBroadcastAddress() throws IOException {
WifiManager myWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
DhcpInfo myDhcpInfo = myWifiManager.getDhcpInfo();
if (myDhcpInfo == null) {
System.out.println("Could not get broadcast address");
return null;
}
int broadcast = (myDhcpInfo.ipAddress & myDhcpInfo.netmask)
| ~myDhcpInfo.netmask;
byte[] quads = new byte[4];
for (int k = 0; k < 4; k++)
quads[k] = (byte) ((broadcast >> k * 8) & 0xFF);
return InetAddress.getByAddress(quads);
}
标签:wifi,广播地址
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
c#测试反射性能示例
2021-12-19 23:13:47
JAVA实现的CrazyArcade泡泡堂游戏
2022-12-25 11:55:23
![](https://img.aspxhome.com/file/2023/6/63156_0s.png)
android studio 新建项目报错的解决之路
2022-09-20 14:24:58
新闻列表的分页查询java代码实现
2022-02-24 19:46:25
Spring Boot 单元测试JUnit的实践
2023-08-29 02:02:15
![](https://img.aspxhome.com/file/2023/7/91127_0s.png)
Android序列化接口Parcelable与Serializable接口对比
2023-03-24 17:48:59
SpringBoot对Controller进行单元测试的实现代码 附乱码解决方案
2021-11-26 17:57:22
![](https://img.aspxhome.com/file/2023/7/88137_0s.png)
Java EE项目中的异常处理总结(一篇不得不看的文章)
2023-06-16 23:35:26
Android仿京东搜索框渐变效果
2022-09-08 19:57:05
![](https://img.aspxhome.com/file/2023/0/114350_0s.gif)
Spring的@Value如何从Nacos配置中心获取值并自动刷新
2022-03-11 02:17:03
Java实现将PDF转为图片格式的方法详解
2022-08-21 07:03:36
![](https://img.aspxhome.com/file/2023/8/122308_0s.jpg)
Android 获取 usb 权限的两种方法
2022-01-06 14:37:06
![](https://img.aspxhome.com/file/2023/0/94240_0s.png)
Spring学习之Bean的装配多种方法
2023-09-04 09:32:36
C#入门之定义类成员与接口实现
2023-05-25 09:50:58
SpringCloud @RefreshScope注解源码层面深入分析
2023-06-14 03:17:27
![](https://img.aspxhome.com/file/2023/9/108389_0s.png)
Android Selector和Shape的使用方法
2022-08-05 23:48:38
![](https://img.aspxhome.com/file/2023/7/106057_0s.gif)
C#获取真实IP地址(IP转为长整形、判断是否内网IP的方法)
2022-01-31 08:50:06
![](https://img.aspxhome.com/file/2023/8/69218_0s.jpg)
Spring JPA配置文件Eclipse报错如何解决
2022-05-07 00:51:34
SpringDataJpa like查询无效的解决
2021-12-02 11:32:40
Java的Comparable,Comparator和Cloneable三大接口详解
2023-07-14 11:18:48
![](https://img.aspxhome.com/file/2023/8/122968_0s.png)