Writing Extension

hello, i need help with extension development. I will try something with webview. but I don’t know how to do event handler. For example, how can we listen to the pageloaded event. From the documentation we can see that it’s like a void function.

How can we call this.

Can anybody help me?

You can check CustomWebView’s source:

1 Like

Events in App Inventor are no different than your regular Java methods other than that they are annotated with @SimpleEvent. To invoke an event, you just need to call the method that represents that event. Here’s an example:

You define your events like this:

@SimpleEvent
public void CalculationDone(int result) {
    EventDispatcher.dispatchEvent(this, "CalculationDone", result);
}

And this is how you invoke them:

@SimpleFunction
public void Calculate(List numbers) {
    final int result = /** perform some intense calculation here */;
    CalculationDone(result);
}

I know it. For examle we know there is no such webview1.setOnPageLoadedListener

WebView component is not actually meant to be used the way you are doing.
You need to create an instance of Android’s webview and not Ai2’s.

1 Like

I also want to listen event for webview instance of ai2

Well unfortunately that is not possible directly…

1 Like

if so, what does this do

That thing refers to the actual Event block of WebViewer component, i.e. PageLoaded.

You mean: I can make own webview extension which able to go to url. But this extension will not have events. if I use ai2 webview

1 Like