안드로이드 MQTT 연동 구현

2017. 9. 10. 17:24안드로이드 개발

엄청 쉽다.


http://androidkt.com/android-mqtt/

Installation

The most convenient way to start a new Android Application is to use Android Studio. Download  Paho Android Service and Android MQTT Client library.Go to your libs folder inside app folder and paste all your .jar

https://repo.eclipse.org/content/repositories/paho-releases/org/eclipse/paho/org.eclipse.paho.android.service/1.1.1/org.eclipse.paho.android.service-1.1.1.jar

https://repo.eclipse.org/content/repositories/paho-releases/org/eclipse/paho/org.eclipse.paho.client.mqttv3/1.1.1/org.eclipse.paho.client.mqttv3-1.1.1.jar


To add the Paho Android Service as a dependency to you app add the following parts to your gradle file.


Permission

The Paho Android Service needs the following permissions to work

To be able to create a binding to the Paho Android Service, the service needs to be declared in the AndroidManifest.xml. Add the following within the <application>tag


Receive MQTT Message


마지막으로 주요 기능을 wrapping한 PahoMqttClient 클래스만 하나 만들어주면 끝!


* MQTT Broker URL의 스키마는 tcp:// 이다!

https://stackoverflow.com/questions/24791118/android-paho-mqtt-service-for-publishing