B4J Tutorial [ABMaterial] Opening your app inside B4A WebView

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.

B4X:
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...

B4X:
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.

B4X:
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.
 

alwaysbusy

Expert
Licensed User
Longtime 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

Expert
Licensed User
Longtime 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:

Mashiane

Expert
Licensed User
Longtime User
Something like this...
videotogif_2018.04.23_17.33.31.gif
 
Top