Android Question how to create browser

Discussion in 'Android Questions' started by Randy B. Calahi, Jul 23, 2019.

  1. Randy B. Calahi

    Randy B. Calahi Member Licensed User

    how to create browser?
     
  2. William Lancee

    William Lancee Member Licensed User

    https://www.b4x.com/android/forum/posts/230988/


    Code:
    Sub Globals
     
    Dim WebV As WebView
    End Sub

    Sub Activity_Create(FirstTime AsBoolean)
     
    Activity.LoadLayout("Layout1")
     WebV.Initialize(
    "WebV")
     
    Activity.AddView(WebV, 0dip0dip100%x100%y)
     WebV.LoadHtml(
    "<html><body background='" & WebViewAssetFile("image.jpg") & "'></body></html>")
    End Sub

    Sub WebViewAssetFile (FileName As StringAs 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
     
    Last edited: Jul 23, 2019
  3. emexes

    emexes Well-Known Member Licensed User

    This is probably not quite what you're looking for, but... while I'm in a extra-spanner-in-the-toolbox frame-of-mind*:

    https://www.b4x.com/android/forum/threads/open-the-browser-with-a-specific-web-page.6666/#content

    which is slightly outdated, but now possibly as simple as:
    Code:
    Private Browser As Intent
    Browser.Initialize(Browser.ACTION_VIEW, 
    "http://www.theage.com.au")
    StartActivity(Browser)
    It does lessen your grip on your user, but to that I would say:

    1/ we love our users
    2/ if you love someone, set them free...

    Or if that doesn't sway you, let's give Isaac Newton a shot:

    If I have seen further it is by standing on ye sholders of Giants.

    :)


    * or possibly an Australian shortcut she'll be right mate frame-of-mind
     
    Last edited: Jul 23, 2019
    Shelby likes this.
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