Android Question events subs in a code module

Mihai Rainer Jr.

Member
Licensed User
Hi, is there any possibility to store events subs in a code module, hence to be accessible to all activities?
For example, I have a socket object declared in the main, and it is used to temporarily connect to a device that only accepts sockets, from different activities, depending on the application's stage. I am finishing other activities so, I need to place the socket_connected sub in a place accessible by all activities. I have tried a lot of things, but with no luck. Also, have searched the forum, but did not find a specific solution.
 

DonManfred

Expert
Licensed User
Longtime User
Hi, is there any possibility to store events subs in a code module
No. Code module can not use Events. Use a Class, a Serive or an Activity.
For the communication part. Put it in the Starter Service is probably the best choice,.
 
Upvote 0

Mihai Rainer Jr.

Member
Licensed User
What I want to achieve is the following:
I have a socket named sock.
I was trying to place sock_connected sub in any places, including in Starter Service, but I am constantly receiving sock_connected was not found.
It is only working if I place it inside the activity code area. But I want it accessible from other activities, too.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
but I am constantly receiving sock_connected was not found
if you are using the code from a service and place the sub in the same service it will work. The Event sub must be in the Service.
Same applies to a activity. The Event sub must be in the Activity.
Same applies to a Class. The Event sub must be in the Class.
 
Upvote 0
Top