如何查看手机获取的ip地址 掩码 网关,掩码,网关和nds

安卓手机通过自动获取ip连上wifi后,怎么查看子网掩码,网关和dns呢? 用ifconfig命令不行_百度知道
安卓手机通过自动获取ip连上wifi后,怎么查看子网掩码,网关和dns呢? 用ifconfig命令不行
我有更好的答案
先自动获取,然后修改为静态IP时就能看见了。不懂如何修改静态IP再问我。
采纳率:20%
是ipconfig
可以看的也可在路由中查看
是安卓手机。。。
那连上网后在路由中看
我就是想用手机看啊。。
本回答被提问者采纳
可以在手机wifi设置里看见啊,里面都有的,你可以看看……
只能看到ip和mac啊,我想看网关和dns
那就通过电脑看下你的无线路由器参数就可以了……
。。。。我就是想用手机看
手机貌似看不到啊……
为您推荐:
其他类似问题
安卓手机的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。如何获得本机的IP地址,子网掩码和网关?如果有多个本地连接时又该如何获取?(急...........)
[问题点数:50分,结帖人eee16]
如何获得本机的IP地址,子网掩码和网关?如果有多个本地连接时又该如何获取?(急...........)
[问题点数:50分,结帖人eee16]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
2005年6月 Delphi大版内专家分月排行榜第二
2005年1月 扩充话题大版内专家分月排行榜第三2005年7月 Delphi大版内专家分月排行榜第三2005年2月 Delphi大版内专家分月排行榜第三
2005年6月 Delphi大版内专家分月排行榜第二
2005年1月 扩充话题大版内专家分月排行榜第三2005年7月 Delphi大版内专家分月排行榜第三2005年2月 Delphi大版内专家分月排行榜第三
匿名用户不能发表回复!|下次自动登录
现在的位置:
& 综合 & 正文
android获取wifi的IP,子网掩码,网关,dns等信息
使用 DhcpInfo 获取这些信息,返回的是一个int型数据,转换下得到想要的信息,代码如下:
public class MainActivity extends Activity {
private WifiManager my_wifiM
private WifiInfo wifiI
private DhcpInfo dhcpI
private TextView tvR
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
my_wifiManager = ((WifiManager) getSystemService("wifi"));
dhcpInfo = my_wifiManager.getDhcpInfo();
wifiInfo = my_wifiManager.getConnectionInfo();
tvResult = (TextView) findViewById(R.id.tvResult);
protected void onResume() {
super.onResume();
StringBuilder sb = new StringBuilder();
sb.append("网络信息:");
sb.append("\nipAddress:" + intToIp(dhcpInfo.ipAddress));
sb.append("\nnetmask:" + intToIp(dhcpInfo.netmask));
sb.append("\ngateway:" + intToIp(dhcpInfo.gateway));
sb.append("\nserverAddress:" + intToIp(dhcpInfo.serverAddress));
sb.append("\ndns1:" + intToIp(dhcpInfo.dns1));
sb.append("\ndns2:" + intToIp(dhcpInfo.dns2));
sb.append("\n");
System.out.println(intToIp(dhcpInfo.ipAddress));
System.out.println(intToIp(dhcpInfo.netmask));
System.out.println(intToIp(dhcpInfo.gateway));
System.out.println(intToIp(dhcpInfo.serverAddress));
System.out.println(intToIp(dhcpInfo.dns1));
System.out.println(intToIp(dhcpInfo.dns2));
System.out.println(dhcpInfo.leaseDuration);
sb.append("Wifi信息:");
sb.append("\nIpAddress:" + intToIp(wifiInfo.getIpAddress()));
sb.append("\nMacAddress:" + wifiInfo.getMacAddress());
tvResult.setText(sb.toString());
private String intToIp(int paramInt) {
return (paramInt & 0xFF) + "." + (0xFF & paramInt && 8) + "." + (0xFF & paramInt && 16) + "."
+ (0xFF & paramInt && 24);
效果如下:
android.net.NetworkUtils
* Convert a IPv4 address from an integer to an InetAddress.
* @param hostAddress an int corresponding to the IPv4 address in network byte order
public static InetAddress intToInetAddress(int hostAddress) {
byte[] addressBytes = { (byte)(0xff & hostAddress),
(byte)(0xff & (hostAddress && 8)),
(byte)(0xff & (hostAddress && 16)),
(byte)(0xff & (hostAddress && 24)) };
return InetAddress.getByAddress(addressBytes);
} catch (UnknownHostException e) {
throw new AssertionError();
附件下载:
【上篇】【下篇】没有更多推荐了,
不良信息举报
举报内容:
Android获取WIFI网关地址与子网掩码地址
举报原因:
原文地址:
原因补充:
最多只允许输入30个字
加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!从哪里可以看到自己宽带的ip地址,还有网关掩码服务器等啊??_百度知道
从哪里可以看到自己宽带的ip地址,还有网关掩码服务器等啊??
我有更好的答案
运行CMD进DOS窗口,输入IPCONFIG
/ALL ,或在网络连接属性里面
采纳率:22%
为您推荐:
其他类似问题
您可能关注的内容
ip地址的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。

我要回帖

更多关于 ip地址和子网掩码计算 的文章

 

随机推荐