Skip to content
Advertisement

Is it possible to detect the Android captive portal browser?

I have a captive portal which, as of Android 5.0+ Lollipop, launches in Android’s Captive Portal Browser rather than the device’s default browser.

I need to somehow detect if they are in the captive portal browser (as opposed to a regular web browser) and if so, show different content.

Is it possible, by examining the User Agent, or through Javascript, to detect if they are within a Captive Portal Browser window? I have looked at the user agents on my Android 5.1 device, but I can’t see anything to differentiate them:

CAPTIVE PORTAL BROWSER:

Mozilla/5.0 (Linux; Android 5.1; Elite 5 Build/LMY47D) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36

REGULAR GOOGLE CHROME:

Mozilla/5.0 (Linux; Android 5.1; Elite 5 Build/LMY47D) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.94 Mobile Safari/537.36

There is a slight difference in the version numbers but this seems inconsistent across Android/Chrome versions and not a reliable way to determine the browser type.

Are there other ways to detect it? Thanks in advance.

Advertisement

Answer

You can use Modernizr to detect the existence of the Fetch API or Local Storage features, both of which exist in regular Google Chrome and Firefox, etc but aren’t available in the captive portal browser.

Advertisement