Android Code Snippet Modify Headers in WebView

You may have to fake its webview making it appear, for example, such as another browser (Mozilla/Chrome + Windows or other ).
You can utilize this code:

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("test_2")
    Dim m As Map
    m.Initialize
    m.Put("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 6.1; zh_CN) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0 baidubrowser/1.x Safari/534.7")
    LoadUrlWithMap(WebView1, "http://www.xxx.com/track/18790907", m)
  
End Sub

Sub LoadUrlWithMap(w As WebView, link As String, m As Map)
   Dim r As Reflector
   r.Target = w
   r.RunMethod4("loadUrl", Array As Object(link, m), _
     Array As String("java.lang.String", "java.util.Map"))
End Sub

Bye
 

Similar Threads

Top