This question is locked. New answers and comments are not allowed.
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
}
}
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
}
}