Android Question View the Desktop version of a site with WebView

Nestor71

Member
Licensed User
Thanks for the reply, I put this code but it always opens the mobile site, where am I wrong?

B4X:
Sub Activity_Create(FirstTime As Boolean)
    
    Activity.LoadLayout("Main")
        
    Dim Obj1 As Reflector
    Obj1.Target = WebView1
    Msgbox(Obj1.ToString, "Target")
    Obj1.Target = Obj1.RunMethod("getSettings")
    Msgbox(Obj1.ToString, "Settings")
  
    Msgbox(Obj1.RunMethod("getUserAgentString"), "User agent")
  
    Obj1.RunMethod2("setUserAgentString", "Desktop", "java.lang.String")
    
    WebView1.LoadUrl("https://www.b4x.com/android/forum/")
    
End Sub
 

Nestor71

Member
Licensed User
I checked the thread I put this code but when I start the app it closes

B4X:
Dim jo As JavaObject = WebView1
Dim settings As JavaObject = jo.RunMethod("getSettings", Null)
settings.RunMethod("setUseWideViewPort", Array(True))
settings.RunMethod("setLoadWithOverviewMode", Array(True))
 

Nestor71

Member
Licensed User
Thanks, with the address https://www.b4x.com/android/forum/ it works but if I put the address I want it comes out written Browser not supported we recommend to use the following Browsers: Google Chrome, Mozilla Firefox, Opera, Microsoft Edge, Safari.
Is there a way to solve it?
 

JohnC

Well-Known Member
Licensed User
The WebviewSettings library I mentioned above has a method to set the useragent:

B4X:
wvs.setUserAgentString(wv,"xxxx")
Do a google search of different user agent strings and see is any of them will give you the result you are looking for.
 
Top