Android Question Pass Parameters From Class to Activity


Licensed User
CallSub3 passes 2 parameters from the class back to the Activity. I know a Class public variable can be seen from the Activity and it works. In the persons demo it does it by the Return in the Class module. Is there a correct way to do this ?


Licensed User
Public variables belong to the class module, getting a parameter by classname.variablename may mix the data between two or more class objects.
The correct way is by callsub with parameters, or return from an existing sub in the class (for 1 parameter). If you need more then 3 - define a type and send the type object as parameter. The types are global so once defined in the class - the main knows the type.
With Return you can continue operation in the calling sub while with callsub you get the response in another sub in the calling module. This difference should control your prefered way of use.
Another important point - with callsub you can use callsubdelayed which lets the program run and not wait for the result (if it is not just waiting for it to continue).
Last edited:


Licensed User
You can also fire a event in activity from your class to give values back to the activity.
using return is the best way i think.
But not all can be done with return. for ex. is something is called which then uses asynchronous things. Then firing an event when the async sub finishes seems to be better

It depends on the needs what to use best

But without seeing any code it is hard to give advices. And telling about any demo does not help too. I dont know from what demo you are talking about! Here in forum are hundrets of demos and i dont know them all