问题
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