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

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