当用户通过强制门户连接到打开的WiFi时,安卓设备将打开一个带有强制门户/登录页面的浏览器实例。
我们想禁用它,因为我们使用了一个应用程序进行登录。
我偶然发现CaptivePortal类变成了Android棉花糖。我可以用它来禁用网络吗?
类名: android.net.CaptivePortal
方法名: ignoreNetwork
如何使用上面的类和方法在WiFi上禁用强制门户的自动启动?
发布于 2017-08-04 10:25:43
试试这个:
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
复制相似问题