Android Question MQTT Background Service

Danbicky

Member
Licensed User
Longtime User
Hi Guys,

I have been playing with some of the examples and tutorials. Freedom your MQTT example is excellent. What I am planning to do as a project is install an android app that runs as a service in the background. Connects and listens to MQTT messages on a broker. If a specific message is received the app will bring up some form of notification and alert sound.

Now I don't know the best way to go about this.

1) Can the service handle all of the MQTT checking and reconnecting in the background?
2) If a message is received do I need to start an activity and load a layout to bring this up on the android display?

Any help on this would be greatly appreciated. Freedoms example works well but is in the foreground.

Big thanks Guys

Dans
 

TommyBee

Member
Licensed User
Longtime User
Here ist the example of MQTT as a service.
You have to start and stop it with the checkbox, otherwise it will run 4 ever in background even if the activity is closed :cool:
It's roughly programmed just as a functioning skeletton you can tweek to your needs, have fun. (any likes welcome :))
 

Attachments

  • mqttService2.zip
    10.3 KB · Views: 782
Upvote 0

Danbicky

Member
Licensed User
Longtime User
Here ist the example of MQTT as a service.
You have to start and stop it with the checkbox, otherwise it will run 4 ever in background even if the activity is closed :cool:
It's roughly programmed just as a functioning skeletton you can tweek to your needs, have fun. (any likes welcome :))
Thanks buddy look forward to trying this :)

Dans
 
Upvote 0

amir hosein

Member
Hell there .
I know that this is an old thread , but I searched for MQTT Service and I found this page of forum only.
Please answer me to solve or find my problem .
I Installed the attached file of this page on 2 device and on both of them it crashed after I enabling the service .
The shown message is : Unfortunately , MQTT-Service2 has stopped .
My 2 device has android 4.2.2 (a Tablet) and Android 5.0 ( a phone)
I should tell you this ,that I installed the MQTT chat on both device and it works fine .

Thanks in advance
Regards
 
Upvote 0
Top