-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CommonAPI Extensions (Android) PropertyBag Properties are not initialized #309
Comments
See linked Issue above. Discovered further evidence that generated property code does not work for Android. Looking at Rhodes Can we please get the documentation synced-up with reality? The current documentation leads developers down a garden path. |
Work-around: initialize properties yourself in implementation. This is not needed for iOS, since the generated base class does it for you. package com.rho.bonjourbrowser;
import java.util.Map;
import com.rhomobile.rhodes.api.IMethodResult;
import com.rhomobile.rhodes.api.MethodResult;
public class BonjourBrowser extends BonjourBrowserBase implements IBonjourBrowser {
public BonjourBrowser(String id) {
super(id);
// Rhodes API code generator does not initialize properties on Android platform.
// So, we have to do it here. I use constants from IBonjourBrowserSingleton.java
// generated file, but the code generator doesn't create any constants for
// default values. So, make sure to verify default values against XML!
setProperty(IBonjourBrowserSingleton.PROPERTY_DOMAIN, "", null);
setProperty(IBonjourBrowserSingleton.PROPERTY_RESOLVE, "true", null);
setProperty(IBonjourBrowserSingleton.PROPERTY_RESOLVE_TIMEOUT, "5.0", null);
setProperty(IBonjourBrowserSingleton.PROPERTY_SEARCHING, "false", null);
setProperty(IBonjourBrowserSingleton.PROPERTY_SERVICE_REGEXP, "", null);
setProperty(IBonjourBrowserSingleton.PROPERTY_SERVICE_TYPE, "_http._tcp.", null);
}
@Override
public void calcSumm(int a, int b, IMethodResult result) {
result.set(a+b);
}
@Override
public void search(Map<String, String> propertyMap, IMethodResult result) {
}
@Override
public void stopSearch(IMethodResult result) {
}
} |
As well, I think it was necessary to use the <TEMPLATES>
<DEFAULT_INSTANCE/>
<PROPERTY_BAG/>
<SINGLETON_INSTANCES/>
</TEMPLATES> |
See:
rhomobile/rhodes#600
If initialization of property-bag properties from XML specification is not supported on Android, it should be documented as such.
It is not possible to build even a simple working Android extension from this documentation. At least not one with properties!
The text was updated successfully, but these errors were encountered: