工程配置

Android-SDK 下载

单击下载Android SDK

Android sdk集成说明

相关限制及注意事项

1、Android SDK 新版支持 api19 以上版本。

2、开发工具AS建议升级到3.0以上版本

导入SDK

解压后将jar包复制到工程的libs目录下面

在build.gradle添加项目依赖

dependencies {
    implementation files('libs/ifly_xiot_最新版本.jar')
}

初始化SDK

在Application中添加如下代码

@Override
public void onCreate() {
    super.onCreate();
    initSdk();
}

private void initSdk() {
    HashParam param = new HashParam();
    param.putParam(XIotMqttConstants.PRODUCT_KEY,"您的ProductKey"));
    param.putParam(XIotMqttConstants.DEVICE_NAME,"您的DeviceName");
    param.putParam(XIotMqttConstants.DEVICE_SECRET,"您的DeviceSecret");
    param.putParam(XIotMqttConstants.API_SECRET,"您的API Secret");
    param.putParam(XIotMqttConstants.API_KEY,"您的API Key");

    if(XIotMqttClient.getInstance() != null) {
        XIotMqttClient.getInstance().destory();
    }
    try{
        XIotMqttClient.createInstance(this.getApplicationContext(),param);
    }catch (XIotException e) {
        Log.e(TAG,"create client failed:"+e);
    }
}

results matching ""

    No results matching ""