B4J Question [abmaterial] why page.isdesktop return true

liulifeng77

Active Member
Licensed User
Longtime User
But I browse the webpage in my mobilephone!

user-agent:Mozilla/5.0 (Linux; Android 6.0.1; SM919 Build/MXB48T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.97 Mobile Safari/537.36

B4X:
Log(AppPage.IsDesktop)
 

alwaysbusy

Expert
Licensed User
Longtime User
hmm, never been made to check it there. You can try adding an UpdateFromCache() in there, but I'm not sure what the consequences are going to be (I don't think this will ever be cleared for example).

In a future version of ABM, I could maybe expose the UserAgent parser in B4J so you could do Page.CheckDevice(req as ServletRequest).

Would return a string like this that you could parse:

B4X:
IsPhone:true;IsTablet:false;IsDesktop:false
 
Upvote 0

liulifeng77

Active Member
Licensed User
Longtime User
I change my code like this:
B4X:
Dim device As String=ws.UpgradeRequest.GetHeader("USER-AGENT")
                If device.IndexOf("Macintosh")>-1 Or device.IndexOf("Windows NT")>-1 then
log("computer")
 
Upvote 0

liulifeng77

Active Member
Licensed User
Longtime User
wait for:page.CheckDevice(req as ServletRequest).:):)
but I wonder know your solution(how to catch the device?),add all device name in a list?
 
Upvote 0
Top