Learning Android Development

Setting UserAgent in Android Webview

Distinguish Between Webview Context and Phone Browser Content

Photo by Lee Campbell on Unsplash

Several years ago, I wrote about making WebView work with Android App. It is not something a native app developer would yearn after, but at times, this would be handy for quicker delivery in some cases.

Nonetheless, from a web page point of view, how do you know if you are being accessed by the Android App or the Browser of the Phone, or even the actual Computer Browser.?

Browser UserAgent

One quick way to differentiate between a Computer and a Phone Browser is to use the UserAgent.

On a Computer Chrome, we can see what’s the UserAgent sent by going to the Developer Tool, and typing window.navigator.userAgent in the console, you’ll be able to get it as shown below

--

--