Cha*_*iya 5 android wifi captivenetwork android-6.0-marshmallow captiveportal
当用户通过强制门户连接到开放 WiFi 时,Android 设备将打开一个带有强制门户/登录页面的浏览器实例。
我们想禁用它,因为我们使用应用程序进行登录。
我在 Android Marshmallow 中遇到了 CaptivePortal 类。我可以用它来禁用网络吗?
类名:android.net.CaptivePortal
方法名称:ignoreNetwork
如何使用上述类和方法在 WiFi 上禁用强制门户的自动启动?
小智 0
尝试这个:
\n\nprivate void CaptivePortalDetectionEnabled() {\n if (CaptiveChange.isChecked()) {\n Settings.Global.putInt(MainActivity.this.getContentResolver(), "captive_portal_detection_enabled", 1);\n Toast.makeText(MainActivity.this, "Captive portal detection is now " + state() + "\\n \xe7\xb6\xb2\xe8\xb7\xaf\xe6\xaa\xa2\xe6\x9f\xa5\xe6\x9c\x8d\xe5\x8b\x99\xe5\xb7\xb2\\"\xe9\x96\x8b\xe5\x95\x9f\\"", Toast.LENGTH_SHORT).show();\n } else {\n Settings.Global.putInt(MainActivity.this.getContentResolver(), "captive_portal_detection_enabled", 0);\n Toast.makeText(MainActivity.this, "Captive portal detection is now " + state() + "\\n \xe7\xb6\xb2\xe8\xb7\xaf\xe6\xaa\xa2\xe6\x9f\xa5\xe6\x9c\x8d\xe5\x8b\x99\xe5\xb7\xb2\\"\xe9\x97\x9c\xe9\x96\x89\\"", Toast.LENGTH_SHORT).show();\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n