Android Question file:///AssetsDir/1a.html

jchal

Active Member
Licensed User
Longtime User
where do i put the 1a.hml file in orede to dysplay it in the AssetsDir?
my code is the following
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
  Dim webview1 As WebView
 
End Sub

Sub Activity_Create(FirstTime As Boolean)
    
    webview1.Initialize("webview1")
    
      
    Dim url="file:///" & File.Combine(File.DirAssets, "1a.html")
    Log("Loading " & url)
    webview1.LoadUrl(url)

    Activity.AddView(webview1, 0, 0, 100%x, 100%y)
End Sub
 

Star-Dust

Expert
Licensed User
Longtime User
Try
B4X:
url="file://" & File.Combine(File.DirAssets, "1a.html")
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
B4X:
WebV.LoadHtml("<html><body background='" & WebViewAssetFile("image.jpg") & "'></body></html>")


Sub WebViewAssetFile (FileName As String) As String
   Dim jo As JavaObject
   jo.InitializeStatic("anywheresoftware.b4a.objects.streams.File")
   If jo.GetField("virtualAssetsFolder") = Null Then
     Return "file:///android_asset/" & FileName.ToLowerCase
   Else
     Return "file://" & File.Combine(jo.GetField("virtualAssetsFolder"), _
       jo.RunMethod("getUnpackedVirtualAssetFile", Array As Object(FileName)))
   End If
End Sub
 
Upvote 0
Top