Android Question Webview in layout not initialized, Android 5.0

nwhitfield

Active Member
Licensed User
Longtime User
I have a curious issue, so far just with the Pre-Launch Reports in Play.

When my app runs for the first time, it displays the EULA. When that's accepted, it loads a new layout, containing a webview, which is required to sign in to a website and authorise the app against a user's account.

This works just fine, and as per the usual instructions, I don't initialize the WebView, because it's loaded via a layout.

Except, every single time, without fail, I get a PLR reporting that on the Huawei P8 Lite, running Android 5.0, there's a fatal exception "Object should first be initialized (WebView)"

Watching the video, this happens exactly where you'd expect it to, at the point where the app should be loading the layout with the WebView. It's tempting, frankly, to just up the minSdk to 23 from the current 21 (so I don't have to check before using fingerprint stuff later on in the app), but I know at least a few of my potential users have crappy old tablets that they'd want to carry on using.

Anyone got any idea why this should happen? This is the only Android 5 device that crops up in the PLR, so I don't know if it happens on others, or is just unique to the Huawei.
 

stevel05

Expert
Licensed User
Longtime User
Presumably you don't have that device to try it on, which makes it harder.

Without seeing your code, it is also a guessing game.

If you are continuing the process immediately, You could try introducing a delay between the load layout and the next process (Sleep(0) should do it) to give the older device time to finish loading the layout before doing anything else.
 
Upvote 0

nwhitfield

Active Member
Licensed User
Longtime User
Here's the code; acceptEula is a button on the first layout; authWeb is my WebView and ui is my user interface class with the post-authorisation logic.

I'll try moving the delay from the end of acceptEULA to after the loadlayout and see if that makes a difference

B4X:
Sub acceptEula_Click
 prefs.Put("eula",True)
 eulaText.Visible = False
 acceptEula.Visible = False
 ToastMessageShow("Thank you",False)
 Sleep(3000)
 If prefs.ContainsKey("authcode") Then
  prefs.close
  ui.Initialize(Activity,True)
  ui.verify_user
 Else
  start_auth
 End If
End Sub

Sub start_auth
 Activity.RemoveAllViews
 Activity.LoadLayout("authpage")
 BLUFtools.FillImageToView(LoadBitmap(File.DirAssets,"fabio.png"),authBG)
 Msgbox2Async("To link this app to your BLUF account, tap Start and then sign in to the website, and grant the app permission. Then tap Done at the top of the screen","Link your BLUF account","Start","","",Null,False)
 Wait For Msgbox_Result (Result As Int)
 blufclub.initialize(True)
 authWeb.LoadUrl(blufclub.getAuthURL & "&token=" & BLUFtools.GetDeviceId)
 authWeb.Visible = True
End Sub
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You have the Wait For in the code, which will effectively do the same thing I think, so it may not make a difference. The other thing I would try would be to load the authpage earlier onto an invisible or hidden pane, and make it visible or bringtofront if needed or remove it from the activity if it's not needed (discarding it).
 
Upvote 0
Top