I have an app with multiple activities that uses mqtt.
I want to connect to the mqtt broker when the app starts then from different activities consume messages from the broker.
I have a separate module with the mqtt code. In the Main activity in Process_Globals I have my MqttClient declared.
In the mqtt module I have my connect code and code for sending an mqtt message. This code works.
I have tried to add the mqtt_connected code to the mqtt module but this doesn't get run when mqtt connects. If the code is in Main then it does get run.
The same is true for the mqtt_MessageArrived.
When I open a different activity I receive log messages 'sending message to waiting queue (mqtt_messagearrived)'
What do I need to do to be able to consume the mqtt messages from different activities (the active activity)?
Thanks.
I want to connect to the mqtt broker when the app starts then from different activities consume messages from the broker.
I have a separate module with the mqtt code. In the Main activity in Process_Globals I have my MqttClient declared.
In the mqtt module I have my connect code and code for sending an mqtt message. This code works.
I have tried to add the mqtt_connected code to the mqtt module but this doesn't get run when mqtt connects. If the code is in Main then it does get run.
The same is true for the mqtt_MessageArrived.
When I open a different activity I receive log messages 'sending message to waiting queue (mqtt_messagearrived)'
What do I need to do to be able to consume the mqtt messages from different activities (the active activity)?
Thanks.