Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Android module creation: pass arguments at creation time

$
0
0

I am working on an android module and have a small but inconvenient issue:

I would like to use my module as follows:

var myModule = require('be.myModule');
 
myModule.createService({
    hostName: Ti.Platform.address,
    port: 40401
});
so I implemented my ServiceProxy as follows:
@Kroll.proxy(creatableInModule=myModule.class)
public class ServiceProxy extends KrollProxy{
    public final String hostName;
    public final int port;
 
    public ServiceProxy(HashMap hashMap) {
    KrollDict arguments = new KrollDict(hashMap);
        if (arguments.containsKey("hostName")) {
            this.hostName = (String)arguments.get("hostName");
        if(arguments.containsKey("port")) {
            this.port = (Integer)arguments.get("port");
    };
}
When I use this module as described, I get the error message: "no empty constructor". I tried to add this empty constructor and also keep the constructor with the hashmap, but when I call createService with the argument, the empty constructor gets executed. Does anybody know how to correctly pass arguments when creating an object(getting an instance of a proxy class). Thanks.

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>