Hi All,
I have a question that I am unable to implement in an example so seeking assistance.
The problem:
I have an mqtt app that is working perfectly fine; and working good in the background until it is killed, so for sure no other messages are being received or sent since the Starter service is killed by OS if I understand correctly.
The solution
Is the tracker example posted by Erel to keep a foreground service notification to keep the service running.
I was looking around if there are any other way as I don't like to keep a notification kept forever and can see that the static receiver will always awake the service, so I am curious if this is a valid option to use the static intent as a broadcastreceiver and to start/wake my mqtt service once there is a message either arrives or sent? if it is can someone provide an example of this?
https://www.eclipse.org/paho/files/android-javadoc/index.html
https://www.eclipse.org/paho/files/...e/paho/android/service/MqttAndroidClient.html
Static receivers
Each service module in Basic4android is made of two components. The service and a receiver. The receiver responsibility is to delegate broadcast intents to the service. For example when you call StartServiceAt, it is the receiver that actually intercepts the intent and wakes the service.
source: https://www.b4x.com/android/forum/t...cepting-sms-messages-in-the-background.20103/
If it is doable then how can I implement it, if someone can provide an example this will be great and appreciate his/her help.
Also I can see there is another library out there that is really great in which I don't need to edit the app manifest, so if I may be greedy to ask for an example using this library if it is doable
https://www.b4x.com/android/forum/threads/broadcastreceiver.12493/
If this is not doable, then I am just curious to know if I published a payload every 5 sec as a keep alive message to the server (and also subscribe to the same topic to receive payload as well) will this be a feasible option to keep my background service running?
My goal:
Is to keep the mqtt background service always running and never stop without having a foreground service (notification).
I have a question that I am unable to implement in an example so seeking assistance.
The problem:
I have an mqtt app that is working perfectly fine; and working good in the background until it is killed, so for sure no other messages are being received or sent since the Starter service is killed by OS if I understand correctly.
The solution
Is the tracker example posted by Erel to keep a foreground service notification to keep the service running.
I was looking around if there are any other way as I don't like to keep a notification kept forever and can see that the static receiver will always awake the service, so I am curious if this is a valid option to use the static intent as a broadcastreceiver and to start/wake my mqtt service once there is a message either arrives or sent? if it is can someone provide an example of this?
https://www.eclipse.org/paho/files/android-javadoc/index.html
https://www.eclipse.org/paho/files/...e/paho/android/service/MqttAndroidClient.html
Static receivers
Each service module in Basic4android is made of two components. The service and a receiver. The receiver responsibility is to delegate broadcast intents to the service. For example when you call StartServiceAt, it is the receiver that actually intercepts the intent and wakes the service.
source: https://www.b4x.com/android/forum/t...cepting-sms-messages-in-the-background.20103/
If it is doable then how can I implement it, if someone can provide an example this will be great and appreciate his/her help.
Also I can see there is another library out there that is really great in which I don't need to edit the app manifest, so if I may be greedy to ask for an example using this library if it is doable
https://www.b4x.com/android/forum/threads/broadcastreceiver.12493/
If this is not doable, then I am just curious to know if I published a payload every 5 sec as a keep alive message to the server (and also subscribe to the same topic to receive payload as well) will this be a feasible option to keep my background service running?
My goal:
Is to keep the mqtt background service always running and never stop without having a foreground service (notification).