Stay connected to WiFi that requires sign-in
You could disable captive portal detection altogether. On Android &lt;= 7.1.1 that is done by:

settings put global captive_portal_detection_enabled 0


For later versions:

settings put global captive_portal_mode 0


For more details please see: Captive Portal parameters.