This is a migrated thread and some comments may be shown as answers.

Android 3rd party library - interface metadata not visible in NativeScript

1 Answer 78 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ram
Top achievements
Rank 1
Ram asked on 18 Mar 2015, 03:57 PM
Hello,

I have a simple JAR library, trying to use it from NativeScript. I able to instantiate the class, but unable to implement the interface.

Demo.jar placed in mylib folder
Next add library to NativeScript project "tns library add android ../mylib"

NativeScript - javascript code

    // below code not working, app crashes -- Demo.Work interface not visible
    var w = new Demo.Worker();
    w.DoWork("hello", Demo.Work({
            Done: function() { alert('done...'); }
         })
    );

    // below code is working -- passing a java class which implements Demo.Work
    var w = new Demo.Worker();
    var callback = new Demo.WorkImpl();
    w.DoWork("hello", callback);


---------------------------- Work.java ------------------------------
package Demo;

public interface Work {
   public void Done();
}


---------------------------- WorkImpl.java ------------------------------
package Demo;

public class WorkImpl implements Work {
    public void Done() {
        System.out.println("done...");
    }
}


---------------------------- Worker.java ------------------------------
package Demo;

public class Worker {
    public void DoWork(String message, Work obj) {
        System.out.println("done..." + message);
        obj.Done(); // callback
    }
}


 











1 Answer, 1 is accepted

Sort by
0
Accepted
Georgi
Telerik team
answered on 18 Mar 2015, 04:16 PM
Hello Ram,

You are correct - currently there is no way to extend an existing class or implement an interface coming from a third-party library. The current version of the Android Runtime uses statically generated bindings and the problem is that there are no bindings generated for the external library.

The good news is we have already implemented a new dynamic binding generator and it is successfully integrated in our development version. We are now thinking how to enable latest development bits as npm packages, so stay tuned, the feature is about to be available very soon.

Regards,
Georgi
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Ram
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or