MQTT android studio
先在APP的build.gradle中的dependencies加入以下紅字 dependencies { compile 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.0' compile 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1' } 然後在 AndroidManifest.xml中加入 <uses-permission android:name="android.permission.INTERNET"> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"> <uses-permission android:name="android.permission.WAKE_LOCK"> 在 AndroidManifest.xml <application 加入 <service android:name="org.eclipse.paho.android.service.MqttService" /> 讓我們做一個MqttHelper import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; import org.eclipse.paho.client.mqttv3.MqttCallback; import org.eclipse.paho.client.mqttv3.MqttClient; import org.eclipse.paho.client.mqttv3.MqttConnectOptions; import org.eclipse.paho.client.mqttv3.MqttException; import org.ec...