Set Android IP,DNS,GATEWAY setting programmatically

后端 未结 4 2186

How do I set wifi ip address, dns address, gateway from android java i.e programmatically, I didn\'t find any method which has the capability to store the values.

4条回答
  •  甜味超标
    2020-11-28 05:39

    the follow code can also do that:

        WifiManager mWifiManager = (WifiManager)mContext.getSystemService(Context.WIFI_SERVICE);
        DhcpInfo dhcpInfo = mWifiManager.getDhcpInfo();
        int dns1 = dhcpInfo.dns1;
        int dns2 = dhcpInfo.dns2;
    

提交回复
热议问题