How to disable network assistant in an Android device?

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

We want to disable it, since we used the application to log in.

I met the CaptivePortal class in Android Marshmallow. Can I use it to disconnect the network?

Class Name: android.net.CaptivePortal

Method Name: ignoreNetwork

How can I use the above class and method to disable automatic port start in portable Wi-Fi mode?

+4
source share
1 answer

try the following:

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();
    }
}
0

Source: https://habr.com/ru/post/1653161/


All Articles