@Override protected AsyncTaskResult<String> doInBackground(final Void... voids) { try { GetThingShadowRequest getThingShadowRequest = new GetThingShadowRequest().withThingName(thingName); GetThingShadowResult result = mIotDataClient.getThingShadow(getThingShadowRequest); byte[] bytes = new byte[result.getPayload().remaining()]; result.getPayload().get(bytes); String resultString = new String(bytes); return new AsyncTaskResult<>(resultString); } catch (Exception e) { if (DEBUG) { Log.e(TAG, "Error on GetShadowTask", e); } return new AsyncTaskResult<>(""); } }
@Override protected AsyncTaskResult<String> doInBackground(Void... voids) { try { GetThingShadowRequest getThingShadowRequest = new GetThingShadowRequest() .withThingName(thingName); GetThingShadowResult result = iotDataClient.getThingShadow(getThingShadowRequest); 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("E", "getShadowTask", e); return new AsyncTaskResult<String>(e); } }