1

I have a native android library, Which expects a java function which works as an event. But in my nativescript plugin, I want to pass javascript function to the library so that library events are fired in javascript runtime.

2
  • Can you please share more info, may be the Java code snippet to understand whether your Java method expects an interface / callable etc., Commented Jun 9, 2019 at 7:01
  • Yes, It expects an interface with 2 methods defined inside. Commented Jun 9, 2019 at 7:06

1 Answer 1

2

If your Java method expects an interface for callback functions, it's already covered in the NativeScript docs.

Java

button.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        // Perform action on click
    }
});

JavaScript

button.setOnClickListener(new android.view.View.OnClickListener({
    onClick: function() {
        // Perform action on click
    }
}));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.