B4J Tutorial [ABMaterial] Opening your app inside B4A WebView

Discussion in 'B4J Tutorials' started by Mashiane, Apr 23, 2018.

  1. Mashiane

    Mashiane Expert Licensed User

    Well

    My intention was to have an Android Play Store for my ABM app. I needed my app to remember the login details, meaning that it needs to access localstorage.

    Thing is, local storage is not accessible with the normal webview. That's where WebViewExtras come in.

    I'm using WebViewExtras2.

    Let's go.

    In Globals, I reference my classes.

    Code:
    Private wbe As WebViewExtras
        
    Private wcc As DefaultWebChromeClient
    In Activity_Create, I start up a few things...

    My webview sits on a layout, so I load the layout first and then...

    Code:
    wbe.Initialize(WebView1)
        wcc.Initialize(
    "wcc")
        wbe.SetWebChromeClient(wcc)
        wbe.GetSettings.SetDOMStorageEnabled(
    True)
        WebView1.JavaScriptEnabled = 
    True
        WebView1.ZoomEnabled = 
    False
        WebView1.LoadUrl(
    "YOUR_URL_FOR_YOUR_ABM_WEBAPP")
    On interesting thing I checked out was the wcc_console when I was running my app.

    Code:
    Sub wcc_ConsoleMessage(ConsoleMessage1 As ConsoleMessage) As Boolean
        
    Log("wcc_ConsoleMessage")
        
    Log(ConsoleMessage1.Message)
    End Sub
    Off course you can remove the console code... but it helps also to see your app execution from the B4A side.

    So I compiled by 1 page app and off to the play store. Installed in on my phone and nicely, I have a nice ABM app running on my Android as if its native, without the necessity of opening a browser.
     
    joulongleu likes this.
  2. alwaysbusy

    alwaysbusy Expert Licensed User

    Wasn't it possible to just build this in the ABM Native Example?

    Note that there is a trend (Apples App store does it already) to ban such apps (just a webview going to a website). So it is quite possible Android will follow quickly. If it is an inhouse app, then you are probably OK.
     
    Mashiane and joulongleu like this.
  3. Mashiane

    Mashiane Expert Licensed User

    Thanks AB for the heads up. I will at some stage educate myself on the ABM Native Platform where a mobile app is of a more emphasis. For now it was just a play and see approach as I'm just starting my focus on small devices. Im sure as more I am comfortable I will evolve to ABM Native. Ta!

    PS: Besides the WebView, on the app I have I resoluted to use the newest image processing that Erel posted for a splash screen. It creates this nice effect of the image pieces coming together whilst the WebView is loading in the background.
     
    Last edited: Apr 23, 2018
  4. Mashiane

    Mashiane Expert Licensed User

    Something like this...
    videotogif_2018.04.23_17.33.31.gif
     
    joulongleu and Harris like 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