Android Question open HTML file in the default Android viewer

Discussion in 'Android Questions' started by sirjo66, Mar 13, 2015.

  1. sirjo66

    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:
    Code:
    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: Mar 13, 2015
  2. mark35at

    mark35at Well-Known Member Licensed User

    What about using the default editor?

    Code:
    Dim ii AsIntent
     ii.Initialize(ii.ACTION_EDIT, 
    "file://" & File.Combine(File.DirDefaultExternal, "guia.htm"))
     ii.SetType(
    "text/html")
    StartActivity(ii)
     
    fredo and thedesolatesoul like this.
  3. sirjo66

    sirjo66 Well-Known Member Licensed User

    No EDIT, I want to VIEW it
     
  4. NJDude

    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.
     
    thedesolatesoul likes this.
  5. sirjo66

    sirjo66 Well-Known Member Licensed User

    SOLVED !!
    Code:
    Dim ii As Intent
        ii.Initialize(ii.ACTION_VIEW, 
    "file://" & File.Combine(File.DirDefaultExternal, "guia.htm"))
        ii.SetType(
    "application/x-webarchive-xml")
        
    StartActivity(ii)
     
  6. NJDude

    NJDude Expert Licensed User

    Like I mentioned on my previous post, better let the user choose, your solution doesn't work on all devices.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice