我正在努力解决一个问题,这个问题是关于在 android 的多个文本视图中显示来自代理服务器的可用 mqtt 主题,并选择其中一个来订阅主题 final MqttAndroidClient client =new MqttAndroidClient(getApplicationContext(),"tcp://iot.eclipse.org:1883","12d45454"); try { client.connect(mqttConnectOptions, null, new IMqttActionListener() { @Override public void onSuccess(IMqttToken mqttToken) { DisconnectedBufferOptions disconnectedBufferOptions = new DisconnectedBufferOptions(); disconnectedBufferOptions.setBufferEnabled(true); disconnectedBufferOptions.setBufferSize(100); disconnectedBufferOptions.setPersistBuffer(false); disconnectedBufferOptions.setDeleteOldestMessages(false); Log.i("ERROR ","Topic="+mqttToken.getTopics()); textview1.setText(mqttToken.getTopics()[0]); }
添加回答
举报
0/150
提交
取消