Access to android resource id in Codename one

13 views
Skip to first unread message

Hasni Faiçal

unread,
Oct 28, 2019, 7:16:43 AM10/28/19
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA
Desktop OS
Simulator 
Device

I am trying to bundle a native android sdk in a CN1 library.
My issue is how access android resource id to do something like the following example in Codename one 

Android code:
getFaudDetectorInstance().registerUsernameField((TextView) R.id.usernameField);
getFaudDetectorInstance().registerPasswordField((TextView) R.id.passwordField);


Shai Almog

unread,
Oct 28, 2019, 10:34:59 PM10/28/19
to CodenameOne Discussions
Using these is problematic from Codename One. There are build hints to inject these things but they generally don't work too well.

In this case it looks like the library is expecting an Android text field/password field. Those are problematic as we only have a native field during the editing process and this field can be used for other things as we construct the UI dynamically. I think the only way you can do something like that is to wrap that whole portion of the UI as a native AAR file which is far from ideal. So ideally there would be a lower level integration point to the library.

Hasni Faiçal

unread,
Oct 30, 2019, 10:02:43 AM10/30/19
to CodenameOne Discussions
 Currently I am looking for a working solution, I will think later how to do it in an ideal way. Do you have any suggestion please how to do this in a native call?

Best regards

Shai Almog

unread,
Oct 30, 2019, 10:53:17 PM10/30/19
to CodenameOne Discussions
I didn't explain this properly... I'm not above "hacking a solution". This isn't that case.

Codename One doesn't create an Android resource file and doesn't use one normally. So these fields/files just don't exist for a Codename One application.
In order to get this you would have to build that entire form in native Android and package that entire thing as an AAR, this might seriously impact the final UX of your application.
Reply all
Reply to author
Forward
0 new messages