How to disable captive network assistant into android device?

爷,独闯天下 提交于 2020-03-18 15:44:11

问题


When a user connects to an open WiFi with a Captive Portal, the Android device will open a browser instance with the captive portal/login page.

We want to disable it, since we used an app for login purposes.

I came across the CaptivePortal Class into Android Marshmallow. Can I use it to disable network?

Class Name: android.net.CaptivePortal

Method Name: ignoreNetwork

How can I use the above class and method to disable auto launch of captive portal on WiFi?


回答1:


try this:

private void CaptivePortalDetectionEnabled() {
    if (CaptiveChange.isChecked()) {
        Settings.Global.putInt(MainActivity.this.getContentResolver(), "captive_portal_detection_enabled", 1);
        Toast.makeText(MainActivity.this, "Captive portal detection is now " + state() + "\n 網路檢查服務已\"開啟\"", Toast.LENGTH_SHORT).show();
    } else {
        Settings.Global.putInt(MainActivity.this.getContentResolver(), "captive_portal_detection_enabled", 0);
        Toast.makeText(MainActivity.this, "Captive portal detection is now " + state() + "\n 網路檢查服務已\"關閉\"", Toast.LENGTH_SHORT).show();
    }
}


来源:https://stackoverflow.com/questions/39251866/how-to-disable-captive-network-assistant-into-android-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!