Persistent Mqtt

Additional

Language
Java
Version
N/A
Created
Jul 24, 2019
Updated
Feb 17, 2020 (Retired)
Owner
Abdullah Zowad Khan (AZKZero)
Contributor
Abdullah Zowad Khan (AZKZero)
1
Activity
Badge
Generate
Download
Source code

PersistentMQTTTest

A sample app demonstrating a quick workaround to using PahoMQTT in Android Oreo+ using foreground notification

Background

  • The PahoMQTT Class is controlled by the singleton ConnectionHolder, which manages the mqttCallback.
  • Due to a restriction on the background services in Android Oreo onwards, the MQTT service is wrapped in the
    NotificationService which is a foreground service with a persistent notification.
  • The notification can be modified, and the sample start button listener can be used to determine how to start the service.