Get WiFi captive portal info

自闭症网瘾萝莉.ら 提交于 2019-12-04 09:55:38
Pawit Pornkitprasan

You'd have to use the new ConnectivityManager.setProcessDefaultNetwork API to force your app to communicate over the captive portal. See https://github.com/pawitp/muwifi-autologin/commit/f045fe36f1fd98a106ea652e2d56f7ddfc871760 for an example.

Complete code added:

final ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
for (Network net : cm.getAllNetworks()) {
    if (cm.getNetworkInfo(net).getType() == ConnectivityManager.TYPE_WIFI) {
        Utils.logDebug(TAG, "Seting process network to " + net);  
        /*Since API 23 ConnectivityManager.setProcessDefaultNetwork(net); 
        is deprecated, use: */
        cm.bindProcessToNetwork(net);
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!