android 6.0.1 force wifi connection with no internet access

前端 未结 2 1652
旧巷少年郎
旧巷少年郎 2021-01-02 00:31

this has many similar questions (google for: \"no internet access detected. won\'t automatically reconnect.\" or: android force wifi connection programmatically).

i

相关标签:
2条回答
  • 2021-01-02 00:37

    A non-root solution which is a kind of hack tech. :P

    1. Reboot phone, connect to the non-Internet Wifi;
    2. Go to Settings and create a new user;
    3. Continue, continue, and continue until you see "Checking connection";
    4. As soon as you see "checking connection", switch off your phone;
    5. Switch on your phone again, you will be in "Owner" user, keep it;
    6. Toggle Wifi, and the exclamation mark should disappear quickly :)
    7. Remove that new user or just leave it there;

    I don't know why, but it works...

    0 讨论(0)
  • 2021-01-02 00:56

    Could you try and set the global setting captive_portal_detection_enabled to 0 (false).

    What's actually happening is that by default, everytime you connect to a wifi, the FW will test against a server (typically google) to see if it's a captive wifi (needs login). So if your wifi is not connected to google, this check will fail. After that, the device knows that wifi has no internet connection and simply will not autoconnect to it.

    Setting this setting to 0, will avoid this check.

    Programatically Settings.Global.putInt(getContentResolver(), Settings.Global.CAPTIVE_PORTAL_DETECTION_ENABLED, 0);

    You can do it through adb for testing purposes:

    adb shell settings put global captive_portal_detection_enabled 0
    

    And retrieve it's value like this:

    adb shell settings list global | grep "captive"
    

    IMHO this is not very nice thing to do, since you are changing a setting for the user and many FWs don't provide even an advanced setting to enable/disable this by the user itself. (Google doesn't). But maybe it suits your needs.

    Hope it helps!

    0 讨论(0)
提交回复
热议问题