23 Nov 2020

[WORKING] WebView to show Desktop View forcibly.


Hi, How are you?

In this post, I shall show you that How can you make your WebView to show only Desktop View forcibly.

Few months ago, I have tried to get way to enforce WebView to show only desktop mode. So I have started to find it on Google, Online fourm & other website. But i didn't get satisfied answers until.

Today i was found way that will absolutely help you to shown Desktop View Mode on Android Device.

So.. let's check it.

DESKTOP USER-AGENT :


String user-agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.99 Safari/537.36";

This is USER-AGENT string. Which will help you to show Desktop View on any device if you use it as USER-AGENT header.

How To implement Desktop User-Agent to WebView?


webview.getSettings().setUserAgentString(user-agent);

webview.getSettings().setUseWideViewPort(true);

webview.getSettings().setLoadWithOverviewMode(true);
// force long width content > device-width to fits into device-width.

MOBILE USER AGENT :

User-agent header: Mozilla/5.0 (Linux; Android 10; SM-J720F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.99 Mobile Safari/537.36


Reaction:

No comments:

No Comments

COMMENT FROM MESSAGE