[Runtime-info] Add guide about app's runtime information 04/141304/2
authorKichan Kwon <k_c.kwon@samsung.com>
Mon, 31 Jul 2017 02:37:40 +0000 (11:37 +0900)
committerEditor Lionbridge <TizenEditor.SEL@lionbridge.com>
Mon, 31 Jul 2017 06:34:10 +0000 (09:34 +0300)
PS2: Reviewed

Change-Id: Ia51c463e0ceca96994af76b1dc23c855c17db2d9
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
org.tizen.guides/html/native/device/runtime_n.htm

index 5a7d19a..4ce84ed 100644 (file)
@@ -32,6 +32,7 @@
                        <li><a href="#prerequisites">Prerequisites</a></li>
                        <li><a href="#get">Getting Runtime Information with a Key-Value Pair</a></li>
                        <li><a href="#get_function">Getting Runtime Information with a Function</a></li>
+                       <li><a href="#get_apps">Getting Application Runtime Information</a></li>
                        <li><a href="#monitor">Monitoring Runtime Information Changes</a></li>
                        <li><a href="#keys">Runtime Information Keys</a></li>
                </ul>
   <p>Tizen provides various runtime information and enables your application to access it and monitor changes in it.</p>
   <p>The main features of the Runtime Information API include:</p>
   <ul>
-  <li>Getting runtime information with a key-value pair
+       <li>Getting runtime information with a key-value pair
        <p>You can <a href="#get">retrieve a runtime information value</a> using its <a href="#keys">key</a>.</p></li>
        <li>Getting runtime information with a function
        <p>You can <a href="#get_function">retrieve runtime information using a function</a> specific to a certain information.</p></li>
+       <li>Getting application runtime information
+       <p>You can <a href="#get_apps">retrieve runtime information about running applications</a>.</p></li>
        <li>Monitoring runtime information changes
        <p>You can <a href="#monitor">register a callback function to monitor specific changes</a> in the runtime information.</p></li>
-       </ul>
+  </ul>
 
 
 <h2 id="prerequisites">Prerequisites</h2>
@@ -123,7 +126,6 @@ func(void)
 }
 </pre></li></ol>
 
-
 <h2 id="get_function" name="get_function">Getting Runtime Information with a Function</h2>
 
 <p>Some runtime information can be retrieved by using a function.</p>
@@ -147,6 +149,54 @@ func(void)
 }
 </pre>
 
+<h2 id="get_apps" name="get_apps">Getting Application Runtime Information</h2>
+
+<p>You can get runtime information on running applications.</p>
+<p>For example, to get the memory usage information for each application:</p>
+
+<pre class="prettyprint">
+void
+print_memory_usage(void)
+{
+    int ret;
+    int i;
+    int count;
+    app_usage_h mem_usage_handle;
+    char *appid;
+    unsigned int usage;
+
+    ret = runtime_info_get_all_apps_memory_usage(&amp;mem_usage_handle);
+    if (ret != RUNTIME_INFO_ERROR_NONE) {
+        /* Error handling */
+    }
+
+    ret = runtime_info_app_usage_get_count(mem_usage_handle, &amp;count);
+    if (ret != RUNTIME_INFO_ERROR_NONE) {
+        /* Error handling */
+    }
+
+    for (i = 0; i &lt; count; i++) {
+        ret = runtime_info_app_usage_get_appid(mem_usage_handle, i, &amp;appid);
+        if (ret != RUNTIME_INFO_ERROR_NONE) {
+            /* Error handling */
+        }
+
+        ret = runtime_info_app_usage_get_usage(mem_usage_handle, i, &amp;usage);
+        if (ret != RUNTIME_INFO_ERROR_NONE) {
+            /* Error handling */
+        }
+
+        dlog_print(DLOG_INFO, LOG_TAG, "appid = %s, usage = %u KB\n", appid, usage);
+        free(appid);
+    }
+
+    ret = runtime_info_app_usage_destroy(mem_usage_handle);
+    if (ret != RUNTIME_INFO_ERROR_NONE) {
+        /* Error handling */
+    }
+}
+</pre>
+
 <h2 id="monitor" name="monitor">Monitoring Runtime Information Changes</h2>
 
 <p>Applications can be notified about changes in the runtime information.</p>
@@ -303,6 +353,7 @@ func(void)
    </tbody>
   </table>
 
+
 <script type="text/javascript" src="../../scripts/jquery.zclip.min.js"></script>
 <script type="text/javascript" src="../../scripts/showhide.js"></script>
 </div></div></div>
@@ -325,4 +376,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga
 </script>
 
 </body>
-</html>
\ No newline at end of file
+</html>