Tuesday, 28 June 2016

android WebView user-agent (office 365 sharepoint doesn't use mobile view on android)

I am trying to show a office 365 sharepoint  page on an Android tablet (with chrome):

However, buy accessing the same url sometimes my tablet get mobile view (layout) and sometime desktop view (layout).

When it get mobile view the url is :

When it not able to get mobile view the url does not change.

I did some research online, people suggest to use web view to make an app and set webview User-Agent, then server side will return right layout. 






I have made an android app, I have tried several different values for User-Agent, but I always get the desktop layout.

I did another search online,  found that they mentioned that different website react User-Agent differently.  (https://mobiforge.com/research-analysis/webviews-and-user-agent-strings)

I finally got this:


They said for office 365, just add “?mobile=1” at the end the URL , it will use mobile view.

after that you will find that you can not change back to desktop view even you try to access different page.

To change it back, then you should apply “?mobile=0” to the URL

No comments:

Post a comment