Android的 - 检测,如果无线需要浏览器登录 [英] Android - Detect if Wifi Requires Browser Login

查看:149
本文介绍了Android的 - 检测,如果无线需要浏览器登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的大学有一个开放的WiFi接入点,但它要求你输入你的电子邮件之前,它可以让你使用网络。我的问题是,WiFi是愚蠢的,因为它似乎将我的连接,并迫使我重新进入我的电子邮件每隔10分钟。

My university has an open wifi access point, however it requires you to enter your e-mail before it allows you to use the web. My problem is that the Wifi is stupid in that it seems to drop my connection and force me to enter my e-mail again every 10 minutes.

我想创建自己的应用程序,我可以用它来自动完成这一步对我来说,但我似乎无法找到任何文件的一个很好的和简单的方法来检测一个WiFi接入点有一个浏览器登录页面。有没有办法在Android中获得这些信息,或者是它只是为了看看我的连接的东西总是重定向到1.1.1.1?

I wanted to create my own app that I can use to automatically do this step for me, but I cannot seem to find any documentation for a nice and easy way to detect if a Wifi access point has a browser login page. Is there a way in Android to get this information, or is it just to see if my connection to something is always redirected to 1.1.1.1?

推荐答案

见的的HttpURLConnection 文档

有些Wi-Fi网络禁止访问Internet,直到用户点击一个登录页面。这样的登录页面通常是$通过使用HTTP重定向psented p $。您可以使用的getURL()来测试,如果你的连接已经意外重定向。此检查是无效已收到响应报头之后,直到,你可以通过调用getHeaderFields()或的getInputStream()触发。

Some Wi-Fi networks block Internet access until the user clicks through a sign-on page. Such sign-on pages are typically presented by using HTTP redirects. You can use getURL() to test if your connection has been unexpectedly redirected. This check is not valid until after the response headers have been received, which you can trigger by calling getHeaderFields() or getInputStream().

他们的样品code有一个片段。这是否将涉及您的特定无线AP,我不能说,但它是值得一试。

They have a snippet of sample code there. Whether this will cover your particular WiFi AP, I can't say, but it is worth a shot.

这篇关于Android的 - 检测,如果无线需要浏览器登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆