@Override protected AsyncTaskResult<String> doInBackground(final Void... voids) { try { UpdateThingShadowRequest request = new UpdateThingShadowRequest(); request.setThingName(thingName); ByteBuffer payloadBuffer = ByteBuffer.wrap(updateState.getBytes()); request.setPayload(payloadBuffer); UpdateThingShadowResult result = mIotDataClient.updateThingShadow(request); byte[] bytes = new byte[result.getPayload().remaining()]; result.getPayload().get(bytes); String resultString = new String(bytes); mLatch.countDown(); return new AsyncTaskResult<>(resultString); } catch (Exception e) { if (DEBUG) { Log.e(TAG, "Error on UpdateShadowTask", e); } mLatch.countDown(); return new AsyncTaskResult<>(e); } }
@Override protected AsyncTaskResult<String> doInBackground(Void... voids) { try { UpdateThingShadowRequest request = new UpdateThingShadowRequest(); request.setThingName(thingName); ByteBuffer payloadBuffer = ByteBuffer.wrap(updateState.getBytes()); request.setPayload(payloadBuffer); UpdateThingShadowResult result = iotDataClient.updateThingShadow(request); byte[] bytes = new byte[result.getPayload().remaining()]; result.getPayload().get(bytes); String resultString = new String(bytes); return new AsyncTaskResult<String>(resultString); } catch (Exception e) { Log.e(UpdateShadowTask.class.getCanonicalName(), "updateShadowTask", e); return new AsyncTaskResult<String>(e); } }