【问题标题】:How to create aws iot Thing with Thing Type using Android SDK如何使用 Android SDK 创建具有事物类型的 aws iot 事物
【发布时间】:2017-11-09 21:45:18
【问题描述】:

我正在使用带有“CreateThingRequest”的 android sdk 创建一个东西。但我无法使用事物类型创建。在java中我找到了“public CreateThingRequest withThingTypeName(String thingTypeName)”方法,但我在android中没有看到任何与此相关的东西。谁能建议我用事物类型创建事物。

【问题讨论】:

    标签: aws-iot


    【解决方案1】:

    如果你升级到最新的 iot sdk,这应该在那里解决。 iot-sdk 2.4.3 版的创建事物请求中存在事物类型名称。

    参考:Github

    【讨论】:

      【解决方案2】:
      public void createThings(final Map < String, String > attributes) {
      
          new Thread(new Runnable() {
              @Override
              public void run() {
                  try {
      
                      CreateThingRequest createThingRequest = new CreateThingRequest();
                      createThingRequest.setThingName(certificateId);
                      AttributePayload attributePayload = new AttributePayload();
                      attributePayload.setAttributes(attributes);
                      createThingRequest.setAttributePayload(attributePayload);
                      CreateThingResult createThingResult = mIotAndroidClient.createThing(createThingRequest);
                      Log.i("Thing Mesage", createThingResult.getThingArn());
                      if (onInitializeMqtt != null)
                          onInitializeMqtt.onInitializeDone(true);
                  } catch (Exception e) {
                      Log.e(LOG_TAG,
                          "Exception occurred when generating new private key and certificate.",
                          e);
                      onInitializeMqtt.onInitializeDone(false);
                  }
              }
          }).start();
      
      
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-08-03
        • 2018-04-22
        • 1970-01-01
        • 1970-01-01
        • 2016-10-01
        相关资源
        最近更新 更多