Android Question open HTML file in the default Android viewer

sirjo66

Well-Known Member
Licensed User
Hello,

I have a file .html that I want to view with default html viewer.

I use this code but it don't works:
B4X:
    Dim ii As Intent
    ii.Initialize(ii.ACTION_VIEW, "file://" & File.Combine(File.DirDefaultExternal, "guia.htm"))
    ii.SetType("text/html")
    StartActivity(ii)
Android ask to me for to select the program that I want to use, but there are only "DB editor" and "HTMLViewer" but don't open default viewer.

Do I need to use Intent.SetComponent ??

Sergio
 
Last edited:

mark35at

Well-Known Member
Licensed User
What about using the default editor?

B4X:
Dim ii AsIntent
 ii.Initialize(ii.ACTION_EDIT, "file://" & File.Combine(File.DirDefaultExternal, "guia.htm"))
 ii.SetType("text/html")
StartActivity(ii)
 

NJDude

Expert
Licensed User
That means there's no default viewer assigned, the user should choose which one to use. Using SetComponent might fail on some devices, they might not have the viewer you indicate.
 

sirjo66

Well-Known Member
Licensed User
SOLVED !!
B4X:
    Dim ii As Intent
    ii.Initialize(ii.ACTION_VIEW, "file://" & File.Combine(File.DirDefaultExternal, "guia.htm"))
    ii.SetType("application/x-webarchive-xml")
    StartActivity(ii)
 

NJDude

Expert
Licensed User
Like I mentioned on my previous post, better let the user choose, your solution doesn't work on all devices.
 
Top