Cleaned up JNI wrapper, android light sensor resource example, notification mechanism...
[platform/upstream/iotivity.git] / service / resource-container / examples / android / AndroidBundle / app / src / main / java / org / iotivity / service / sample / androidbundle / AndroidLightResource.java
1 package org.iotivity.service.sample.androidbundle;\r
2 \r
3 import android.content.Context;\r
4 import android.util.Log;\r
5 \r
6 import org.iotivity.service.resourcecontainer.AndroidBundleResource;\r
7 import org.iotivity.service.resourcecontainer.RcsResourceAttributes;\r
8 \r
9 /**\r
10  * Created by markus.jung on 11/8/2015.\r
11  */\r
12 public class AndroidLightResource extends AndroidBundleResource {\r
13     private static final String LOG_TAG = AndroidLightResource.class.getSimpleName();\r
14     public AndroidLightResource(Context context){\r
15         super(context);\r
16         this.setResourceType("oic.r.light");\r
17         this.setName("androidLightResource");\r
18     }\r
19     @Override\r
20     protected void initAttributes() {\r
21         this.m_attributes.put("on-off", false);\r
22     }\r
23 \r
24     @Override\r
25     public void handleSetAttributesRequest(RcsResourceAttributes attrs) {\r
26 \r
27         for(String key: attrs.keySet()){\r
28             Log.i(LOG_TAG, " " + key + ": " + attrs.get(key));\r
29         }\r
30 \r
31         Log.i(LOG_TAG, "Set Attributes called with " + attrs);\r
32 \r
33         Log.i(LOG_TAG, "On-off value: " + attrs.get("on-off"));\r
34     }\r
35 \r
36     @Override\r
37     public RcsResourceAttributes handleGetAttributesRequest() {\r
38         Log.i(LOG_TAG, "Get Attributes called");\r
39         Log.i(LOG_TAG, "Returning: ");\r
40         for(String key: m_attributes.keySet()){\r
41             Log.i(LOG_TAG, " " + key + ": " + m_attributes.get(key));\r
42         }\r
43         return this.m_attributes;\r
44     }\r
45 }\r