AFAIK we don't have a workaround for this bug. Feel free to file an issue on that with a suggestion for that workaround.
On Thursday, February 4, 2021 at 11:54:50 AM UTC+2 P5music wrote: > On Android that issue can be very nasty also on the separate Chrome > WebView (or maybe it was, I do not know if now it is fixed), so the only > workaround is taking into account what really happens. > It is mainly because the two methods are not always called in the same > order. > And nothing prevents the WebView from firing again for no reason shortly > after, so it can happens more than twice. I think this is/was a bug. > > I can say what I am doing in my CodenameApp: > I have a class boolean variable, like onLoadEventAlreadyCalled. One > different variable has to be used for each BrowserComponent. > I have two BrowserComponents in two different classes. > > The trick is to set the boolean to false > *each time* > a method is called that can originate a "onLoad" event (case sensitive or > use BrowserComponent.onLoad const), > > then in the listener (addWebEventListener) have: > > if (onLoadEventAlreadyCalled) return; > onLoadEventAlreadyCalled=true; > > It is important to set the boolean to false before calling any methods > that can originate the event because otherwise the code will be executed > only the first time. > > So it depends on your implementation. I experienced two events, so what > method are you using? It could be that the same method is being called > twice, as I said. > > Regards > > Il giorno giovedì 4 febbraio 2021 alle 03:50:06 UTC+1 Shai Almog ha > scritto: > >> The iOS API is generally better/more consistent than the Android API and >> doesn't have as many quirks. If you can provide a reference to the >> recommended Android workaround we can incorporate it. >> >> On Wednesday, February 3, 2021 at 5:26:30 PM UTC+2 P5music wrote: >> >>> I have development experience on Android, >>> and I know that the WebView has some quirkness, for example it has two >>> methods for catching the "onload" event. In one Android app I had to manage >>> that with a workaround. >>> >>> My Android build of the CodenameApp seems to have that issue too. >>> >>> Indeed on the simulator the onload callback is called once >>> while >>> on the Android device it is called twice. >>> >>> I realized that because I put logging instructions, and also I saw some >>> functions being called twice. >>> >>> Are you aware that the callbacks of "onload" event could be called twice >>> on the Android devices? >>> I think it is important. >>> >>> Can you fix that or I have to create a workaround? >>> >>> And do you know about this issue on iOS devices? >>> >>> Thanks in advance >>> >> -- You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/e3d0bf4a-d269-40f8-af6e-d2ba2d0b0c3fn%40googlegroups.com.
