Java 类com.amazonaws.services.iotdata.model.UpdateThingShadowResult 实例源码

项目:DeviceConnect-Android    文件:AWSIotController.java   
@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);
    }
}
项目:aws-sdk-android-samples    文件:TemperatureActivity.java   
@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);
    }
}