在下面的代码中,我试图为持久数据创建一个文件夹。如您所见,我创建private final String folder = "//temp";
了对象persistence
。但问题是当我运行应用程序时,我说Connection Failed
,这条消息来自client connection synchronous listener
,当我在没有对象的情况下连接时persistence
,一切正常。
我是错误地初始化folder
变量还是使用 MqttClientPersistence persistence
不正确?
代码:
private final String folder = "//temp";
private final int keepAliveInterval = 30;
private final String TAG = this.getClass().getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mqtt_proj_01_layout);
final MqttClientPersistence persistence = new MqttDefaultFilePersistence(folder);
final MqttAndroidClient client2 = new MqttAndroidClient(getApplicationContext(), serverURI, clientID,persistence);