How to create aws iot Thing with Thing Type using Android SDK

Srikanth M Source

i am creating a thing using android sdk with "CreateThingRequest". But i am unable to create with Thing Type. In java i found "public CreateThingRequest withThingTypeName(String thingTypeName)" method, but i have not seen anything related to this in android. Can anyone suggest me to create Thing with Thing Type.

aws-iot

Answers

answered 1 year ago flingo_1992 #1

If you upgrade to the latest iot sdk, this should be solved there. Thing type name is present in the create thing request in iot-sdk version 2.4.3.

Ref: Github

answered 1 year ago nick #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();


}

comments powered by Disqus