How to pass values from the Desginer to the OnCreate Function?

41 views
Skip to first unread message

Sander Jochems

unread,
Aug 18, 2017, 9:39:42 AM8/18/17
to App Inventor Open Source Development
Hello,

How can I pass a value from a Property in the Designer from From.java to the OnCreate Function in the Form.java?

Thanks,
Sander Jochems

Moliata

unread,
Aug 18, 2017, 1:57:06 PM8/18/17
to App Inventor Open Source Development
Hello, Sander. There is onCreateFinish() method inside Form.java, it is being called after onCreate() but before Initialize event.

Sander Jochems

unread,
Aug 19, 2017, 6:32:54 AM8/19/17
to App Inventor Open Source Development
Well, what I want is only possible at the start of the OnCreate Function, so that doesn't help much

Moliata

unread,
Aug 19, 2017, 9:34:37 AM8/19/17
to App Inventor Open Source Development
So? You wanted to put methods which occurs in onCreate, onCreateFinish is used for that. When OnCreate method called it runs a few lines of code & then it runs onCreateFinish() method, which means, that onCreate finish executing only when onCreateFinish fully executes.

Sander Jochems

unread,
Aug 20, 2017, 11:56:14 AM8/20/17
to App Inventor Open Source Development
I need to add a line of code at the start of the OnCreate Function. Not anywhere else. So my question is how can I get a value from the Designer to the OnCreate Function?

Evan Patton

unread,
Aug 22, 2017, 2:15:52 PM8/22/17
to App Inventor Open Source Development
In general this is not possible. By the time the Companion has initialized the onCreate method will have already been called. However, for compiled apps you could pass a value via project.properties to the Compiler class in the buildserver to have it included as part of the application's resources. You would then read property out of the resources bundle in the onCreate function.

Evan
Reply all
Reply to author
Forward
0 new messages