build.gradle
file of your project:compiledSdkVersion
to 31 at least, enable multidex and dataBinding then add MQTT chat artifacts as a dependencies in the build.gradle
file of your main app. Application
class of your android app add the following code to init MQTT hat: You get your own APP_ID
and APP_SECRET
after registration to admin Panel.loginIn()
function must be called in your LoginActivity
just after user login success to your application. It allows to save the user id in a file and therefore you d'ont need to login the user each time you launch application. loginIn()
function can be executed offline and the saved user id can only be cleared by executing logOut()
function.userId
is the primary field value of your users table in application database.FrameLayout
component to MainActivity layout activity_layout.xml. oncreate()
method of your main activity, affect MqttchatFragment
to FrameLayout
component.PresenceActivityA
to keep presence system running in all activities of you Application. Except for activities called when user is not yet logged to MQTT chat like Register or Login activities.startChatWith()
function.