Buy any Easy Native Extensions 2nd Edition package and get our $99 iOS + Android ANE Template completely free before the end of June 2015.
- step-by-step guide to making your iOS extension in under an hour
- library for data conversion between ActionScript and native code
- tutorials
- infographics
- code included
Do you remember when we talked about what an Extension Initializer and Finalizer are and what happens if they don’t have unique names? We also saw what they look like in C. Today we are contrasting that with their Java versions.
Extension Initializer in Java – FREExtension : initialize()
Unlike its C counterpart, which asks of you you to implement a function for the extension initializer, the AIR Java API requires you to implement a class that represents your extension: FREExtension.
The Extension Initializer is a method of this class and is called initialize:
1 2 |
@Override public void initialize() |
Extension Finalizer in Java – FREExtension : dispose()
Looking at the signature for the Initializer, can you guess what the Extension Finalizer looks like? Yep, it’s another method in your implementation of the FREExtension class. Now, can you guess what it’s called? I bet you didn’t expect that:
1 2 |
@Override public void dispose() |
Yeah, I agree, the section title was a bit of a spoiler…
FREExtension implementation
So what do these look like in the actual class? Here is an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
public class SpeechRecognizerExtension implements FREExtension { @Override public void initialize() { ... } @Override public void dispose() { ... } } |
What’s next?
Next we will look at what’s an Extension Context and what’s an Extension Context Initializer and Finalizer.
Then we will see in what order all of these initializers and finalizers are called when your ANE is loaded and when it’s unloaded.
Also, have a look at the C versions of the Extension Initializer and Finalizer.
Over to you
Do you have a convention for naming your FREExtension implementation? What is it? Tell us in the comments below.
Leave a Reply