This shell command works on android version 6.0+ : type su to enter superuser mode. Then type the following command:
settings put global captive_portal_detection_enabled 0
This command disables the “drop wifi if no internet connection” functionality and stops checking if internet access is available.