相关命令:https://www.cnblogs.com/quitboy/p/4795738.html
参考文档:http://emqtt.com/docs/v2/commands.html
心得:https://blog.csdn.net/qq_29261497/article/details/52954749?locationNum=8&fps=1
收藏的关于mqtt的示例:https://github.com/fighter-lee/EasyMqtt
emqttd服务器测试与启动:https://blog.csdn.net/frankcheng5143/article/details/52045501
MainActivity:
package com.example.lwhenyoucai.myemqttedmo;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import org.fusesource.hawtbuf.Buffer;
import org.fusesource.hawtbuf.UTF8Buffer;
import org.fusesource.mqtt.client.Callback;
import org.fusesource.mqtt.client.CallbackConnection;
import org.fusesource.mqtt.client.Listener;
import org.fusesource.mqtt.client.MQTT;
import org.fusesource.mqtt.client.QoS;
import org.fusesource.mqtt.client.Topic;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
Button sendBt,connBt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}
private void initView() {
sendBt = (Button) findViewById(R.id.sendBt);
connBt = (Button) findViewById(R.id.connBt);
Mytopic = new ArrayList<>();
getTopic();
}
public void conn(View view){
connectToServer("client1");
}
public void send(View view) {
Toast.makeText(MainActivity.this,