How can I automatically re-connect to a WiFi network?


Question

In this question I am asking about how to stop my WiFi from disconnecting.



If I won't find an answer to that, the next best thing is to get my phone to re-connect automatically. The disconnect reason is: "Class 3 frame received from nonassociated STA"



I am on a rooted device running cyanogen mod on Android 5.



I'm using AFWall+ and OpenVPN, if that is relevant. OpenVPN is set to re-connect automatically already, which works.



Due to AFWall+ blocking non-vpn traffic, whenever I connect to WiFi it says "There is no Internet connectivity, do you still want to connect? [Yes/No]", ticking the "Don't ask again" box has no effect.

This might be relevant and if the phone does automatically reconnect, I obviously don't want this pop-up to prevent an automated re-connect.


Answer

Your issue is caused by Captive Portal¹ Check kicking in and not permitted through by AFWall+. So if you can live without that auto-detection, you could simply disable it:





# check what the original setting is. Should give "1" for enabled, "0" for disabled
settings get global captive_portal_detection_enabled
# now let's disable it
settings put global captive_portal_detection_enabled 0
# if you want to re-activate it
settings put global captive_portal_detection_enabled 1


Implications:




  • no more pop-ups when connecting to e.g. a hotel network using Captive Portal. Easy work-around: just open a web browser and navigate to any url, the portal should "capture" you for login

  • no more x on the WiFi symbol – so you might miss the fact of not reaching any network until you try manually (e.g. by visiting some web page and ending up on the Captive Portal's login page)

  • automatic re-connect to "known WiFis" should simply work.



I've used that trick myself when having set up AFWall+ in a quite restricting mode, and it worked for me. As you (OP) just confirmed in a comment on the question, it did the trick for you as well – despite the additional complication of a VPN.



See Captive Portal parameters for more details on manipulation.






¹ for those who don't know what a "Captive Portal" is, please see Wikipedia


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes