When you connect to a Wi-Fi network that requires authentication, Android sends you to the network authentication page by a redirect generally sent by the link connectivitycheck.gstatic.com/generate_204 or by link clients3.google.com/generate_204 or similar links.
In the application I'm developing, I want to do this automatically by the app. I want it to get the redirected address and log in to the network using that address.
How can I get access to these links within the application and get the link to which they redirect, all in the background?
In addition, how can I check to see if the user is logged in and with wifi access?
Editing to complement: I will better describe the situation in context.
My application has saved user login and password. So it opens internally the wifi login page and log in with the saved information. The problem is just having known the url.
This problem happens because it is never the same url. It changes every login attempt, due to the different token that is generated each time login.
My goal is to somehow get this url to send to the login function, and so know the url to send to the function.