Android Question [SOLVED] WebViewExtras lib

Lello1964

Well-Known Member
Licensed User
Longtime User
Hello,
i'm tryning to open xml file with xls scheme using WebViewExtras lib,
this my code :
B4X:
Sub Globals
    Dim WebView1 As WebView
   Dim WebViewExtras1 As WebViewExtras
   Dim WebViewSetting As WebViewSettings
   Dim DBFileDir As String                   : DBFileDir =RP1.GetSafeDirDefaultExternal("")
End Sub

Sub Activity_Create(FirstTime As Boolean)
   WebView1.Initialize("WebView1")
  
   WebViewExtras1.addWebChromeClient(WebView1, "")
   Activity.AddView(WebView1, 0, 0, 100%x, 100%y)
  
   Dim url="file:///" & File.Combine(DBFileDir, "IT00430310672_0001N.xml")
   Log("Loading " & url)
   WebView1.LoadUrl(url)
  
End Sub
[code/]

both file xls and xlm are ... /Android/data/xmkl.test/files/

i have this error :

Logger connesso a:  Xiaomi Redmi Note 3
--------- beginning of system
--------- beginning of main
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Loading file:////storage/emulated/0/Android/data/xmkl.test/files/IT00430310672_0001N.xml
Unsafe attempt to load URL file:///storage/emulated/0/Android/data/xmkl.test/files/fatturapa_v1.2.xsl from frame with URL file:///storage/emulated/0/Android/data/xmkl.test/files/IT00430310672_0001N.xml. 'file:' URLs are treated as unique security origins.
 in file:///storage/emulated/0/Android/data/xmkl.test/files/IT00430310672_0001N.xml (Line: 2)
** Activity (main) Resume **

how can i solve ?
 

Lello1964

Well-Known Member
Licensed User
Longtime User
Try to load it from File.DirInternal.
Erel, thanks for answare, but i have tryed to open XML files using File Manager with default Smartphone browser and i have some blank image.
If i use Mozilla to open XML i will see XML with XSL format correct.
I think cannot solve this problem.
 
Upvote 0

Lello1964

Well-Known Member
Licensed User
Longtime User
[SOLVED]
B4X:
    Dim jo As JavaObject = WebView1
   Dim settings As JavaObject = jo.RunMethod("getSettings", Null)
   Dim r As Reflector
   r.Target = settings
   r.RunMethod2("setAllowUniversalAccessFromFileURLs", True, "java.lang.boolean")
 
Upvote 0
Top