Hi, I was planning to use your extension and onReceive. I have to say that the notifications keep working repeatedly. That’s why I added a command in the onReceive procedure to connect via MQTT to the broker, and then I activate a timer which, after 45 seconds, reads the topic from the broker and disconnects.
I found out that the condition checking whether the MQTT client is connected doesn’t work. It seems to me that usrPahoMqttClient and timers don’t work inside onReceive. Do they need to be activated somehow?
Normally, in itoo it worked for me for at least 6 hours. When it didn’t work, I tried to activate itoo in the background if Android killed it. That also didn’t work out.
What am I doing wrong? Thank you very much for your help.
The alarmmanager uses the itooX framework, so all rules relevant for itoo are also relevant for the background processing of the alarmmanager. So the answer is yes, do it the same as you would use itoo
This should return false even if you started the connection in the foreground, i.e. do not mix foreground and background processing, i.e. start your connection in the background in the OnReceive event handler
To send a notification you could also use the StartNow method from the alarmmanager extension
Also for debugging use the Notifier.LogInfo method and use Logcat to check the log
I currently do not have a link to the documentation of the mqtt extension...
You might want to register that event for itoo ... same for other relevant mqtt events...
What I forgot to ask earlier, I'm assuming, you added also the itoo extension? Without that extension obviously background processing is not possible
Example 2: display the current weekday at alarm time
start a repeating alarm and at alarm time in the OnReceive event handler get the current weekday and display the notification using the StartNow method