[RE] Added NULL check in Android sample application.
authorJay Sharma <jay.sharma@samsung.com>
Fri, 28 Apr 2017 18:12:12 +0000 (23:42 +0530)
committerUze Choi <uzchoi@samsung.com>
Wed, 3 May 2017 04:46:21 +0000 (04:46 +0000)
Bug : https://jira.iotivity.org/browse/IOT-2141
Change-Id: I6a77b388b401d9ee5364e9de2859e1c91978fca5
Signed-off-by: Jay Sharma <jay.sharma@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/19447
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/resource-encapsulation/examples/android/RESampleClientApp/app/src/main/java/org/iotivity/service/sample/client/ResourceClientActivity.java

index fd392f5..b4a693e 100644 (file)
@@ -204,8 +204,12 @@ public class ResourceClientActivity extends Activity
     private Item mGetCachedAttribute = new Item("8. Get Cached Attribute") {
         @Override
         public void execute() throws RcsException {
-            printLog(ATTR_KEY_TEMPERATURE + " : " + mResourceObj
-                    .getCachedAttribute(ATTR_KEY_TEMPERATURE).asInt());
+            RcsValue value = mResourceObj.getCachedAttribute(ATTR_KEY_TEMPERATURE);
+            if (null != value) {
+                printLog(ATTR_KEY_TEMPERATURE + " : " + value.asInt());
+            } else {
+                printLog("Cache data is not available");
+            }
         }
     };