[TCSACR-60,91][Tizen.Context.AppHistory] Add API guide 69/151069/3
authorSomin Kim <somin926.kim@samsung.com>
Tue, 19 Sep 2017 13:44:14 +0000 (22:44 +0900)
committerEditor Lionbridge <TizenEditor.SEL@lionbridge.com>
Wed, 20 Sep 2017 12:00:49 +0000 (15:00 +0300)
PS3: Reviewed

Change-Id: I876098999d53e547b95e2cdf9de3d505890987d7
Signed-off-by: Somin Kim <somin926.kim@samsung.com>
org.tizen.guides/html/dotnet/app_history.htm [new file with mode: 0644]

diff --git a/org.tizen.guides/html/dotnet/app_history.htm b/org.tizen.guides/html/dotnet/app_history.htm
new file mode 100644 (file)
index 0000000..2645768
--- /dev/null
@@ -0,0 +1,167 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+       <head>
+               <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+               <meta http-equiv="X-UA-Compatible" content="IE=9" />
+               <link rel="stylesheet" type="text/css" href="../css/styles.css" />
+               <link rel="stylesheet" type="text/css" href="../css/snippet.css" />
+               <script type="text/javascript" src="../scripts/snippet.js"></script>
+               <script type="text/javascript" src="../scripts/jquery.util.js" charset="utf-8"></script>
+               <script type="text/javascript" src="../scripts/common.js" charset="utf-8"></script>
+               <script type="text/javascript" src="../scripts/core.js" charset="utf-8"></script>
+               <script type="text/javascript" src="../scripts/search.js" charset="utf-8"></script>
+
+               <title>Application History</title>
+       </head>
+
+       <body onload="prettyPrint()" style="overflow: auto;">
+               <div id="toc-navigation">
+
+                       <div id="toc_border"><div id="toc">
+                       <p class="toc-title">Dependencies</p>
+                       <ul class="toc">
+                               <li>Tizen 4.0 and Higher</li>
+                       </ul>
+                       <p class="toc-title">Content</p>
+                       <ul class="toc">
+                               <li><a href="#prerequisites">Prerequisites</a></li>
+                               <li><a href="#retrieve_usage_stats">Retrieving Application Usage Statistics</a></li>
+                               <li><a href="#retrieve_battery_stats">Retrieving Battery Usage Statistics</a></li>
+                       </ul>
+                       <p class="toc-title">Related Info</p>
+                       <ul class="toc">
+                               <li><a href="https://developer.tizen.org/dev-guide/csapi/namespaceTizen_1_1Context_1_1AppHistory.html">Tizen.Context.AppHistory Namespace</a></li>
+                       </ul>
+                       </div></div>
+               </div>
+
+               <div id="container"><div id="contents"><div class="content">
+
+               <h1>Application History</h1>
+               <p>You can retrieve the user's application usage patterns, such as information about frequently used applications.</p>
+               <p>The main features of the Tizen.Context.AppHistory namespace are:</p>
+               <ul>
+                       <li>Retrieving application usage statistics
+                               <p>You can <a href="#retrieve_usage_stats">retrieve application launch history</a>, such as frequently used applications and recently used applications, using the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Context_1_1AppHistory_1_1UsageStatisticsData.html">Tizen.Context.AppHistory.UsageStatistics</a> class.</p>
+                       </li>
+
+                       <li>Retrieving battery usage statistics
+                               <p>You can <a href="#retrieve_battery_stats">retrieve battery usage statistics</a>, using the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Context_1_1AppHistory_1_1BatteryStatistics.html">Tizen.Context.AppHistory.BatteryStatistics</a> class.</p>
+                       </li>
+               </ul>
+
+
+       <h2 id="prerequisites">Prerequisites</h2>
+
+<p>To enable your application to use the application history functionality:</p>
+<ol>
+<li>To use the <a href="https://developer.tizen.org/dev-guide/csapi/namespaceTizen_1_1Context_1_1AppHistory.html">Tizen.Context.AppHistory</a> namespace, the application has to request permission by adding the following privilege to the <code>tizen-manifest.xml</code> file:
+<pre class="prettyprint">
+&lt;privileges&gt;
+   &lt;privilege&gt;http://tizen.org/privilege/apphistory.read&lt;/privilege&gt;
+&lt;/privileges&gt;
+</pre>
+</li>
+<li>To use the methods and properties of the Tizen.Context.AppHistory namespace, include it in your application:
+<pre class="prettyprint">
+using Tizen.Context.AppHistory;
+</pre>
+</li>
+</ol>
+
+       <h2 id="retrieve_usage_stats">Retrieving Application Usage Statistics</h2>
+<p>To retrieve application usage statistics for a given time period, and check detailed statistics information, such as duration, launch count, and last launch time of the used applications:</p>
+<ol>
+<li>To retrieve the application launch history, create a usage statistics instance:
+       <ul>
+               <li>To use the default <code>LaunchCountMost</code> sort order, create a new instance of the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Context_1_1AppHistory_1_1UsageStatistics.html">Tizen.Context.AppHistory.UsageStatistics</a> class without specifying the <code>sortOrder</code> parameter:
+<pre class="prettyprint">
+UsageStatistics frequentlyUsedApp = new UsageStatistics();
+</pre>
+               </li>
+               <li>To use another sort order for your usage statistics instance, add the <code>sortOrder</code> parameter to the <code>Tizen.Context.AppHistory.UsageStatistics</code> class constructor, using values of the <code>Tizen.Context.AppHistory.UsageStatistics.SortOrderType</code> enumeration:
+<pre class="prettyprint">
+UsageStatistics recentlyUsedApp = new UsageStatistics(UsageStatistics.SortOrderType.LastLaunchTimeNewest);
+</pre>
+               </li>
+       </ul>
+</li>
+<li>To get information about the most frequently used applications for a given time period, use the <code>Query()</code> method of the <code>Tizen.Context.AppHistory.UsageStatistics</code> class:
+       <ul>
+               <li>To retrieve a list of frequently used applications for a given time period, specify the <code>startTime</code> and the <code>endTime</code> parameters to determine the time period.
+               <p>For example, to retrieve a list of the most frequently used applications for the last 2 weeks:</p>
+<pre class="prettyprint">
+IReadOnlyList&lt;UsageStatisticsData&gt; frequentlyUsedAppList = frequentlyUsedApp.Query(DateTime.Now.AddDays(-14), DateTime.Now);
+</pre>
+               </li>
+               <li>By default, the query returns a maximum of 10 results. You can change the number of returned results by setting the <code>resultSize</code> parameter.
+               <p>For example, to retrieve a list of 5 most frequently used applications for the last 2 weeks:</p>
+<pre class="prettyprint">
+IReadOnlyList&lt;UsageStatisticsData&gt; frequentlyUsedAppList = frequentlyUsedApp.Query(DateTime.Now.AddDays(-14), DateTime.Now, 5);
+</pre>
+               </li>
+<li>The query returns a sorted list of <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Context_1_1AppHistory_1_1UsageStatisticsData.html">Tizen.Context.AppHistory.UsageStatisticsData</a> class instances. To enumerate the list:
+<pre class="prettyprint">
+foreach(var record in frequentlyUsedAppList)
+{
+    Log.Info(LOGTAG, "AppId: " + record.AppId);
+    Log.Info(LOGTAG, "Duration: " + record.Duration);
+    Log.Info(LOGTAG, "LaunchCount: " + record.LaunchCount);
+    Log.Info(LOGTAG, "LastLaunchTime: " + record.LastLaunchTime);
+}
+</pre>
+</li>
+       </ul>
+</li>
+
+</ol>
+
+       <h2 id="retrieve_battery_stats">Retrieving Battery Usage Statistics</h2>
+<p>To retrieve battery usage statistics for a given time period, and check detailed statistics information, such as the battery consumption of the used applications:</p>
+<ol>
+       <li>To retrieve the battery consumption per application, create an instance of the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Context_1_1AppHistory_1_1BatteryStatistics.html">Tizen.Context.AppHistory.BatteryStatistics</a> class:
+<pre class="prettyprint">
+BatteryStatistics batteryConsumedApp = new BatteryStatistics(BatteryStatistics.SortOrderType.ConsumptionMost);
+</pre>
+       </li>
+       <li>To get the information about the application battery consumption, use the <code>Query()</code> method of the <code>Tizen.Context.AppHistory.BatteryStatistics</code> class.
+       <p>For example, to retrieve battery consumption history since the device was last fully charged, use a <code>DateTime</code> instance returned by the <code>GetLastFullyChargedTime()</code> method as the <code>startTime</code> parameter of the <code>Query()</code> method:</p>
+<pre class="prettyprint">
+DateTime time = BatteryStatistics.GetLastFullyChargedTime();
+IReadOnlyList&lt;BatteryStatisticsData&gt; batteryConsumedAppList = batteryConsumedApp.Query(time, DateTime.Now, 5);
+</pre>
+       </li>
+       <li>The <code>Query()</code> method returns a sorted list of <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Context_1_1AppHistory_1_1BatteryStatisticsData.html">Tizen.Context.AppHistory.BatteryStatisticsData</a> class instances. To enumerate the list:
+<pre class="prettyprint">
+foreach(var record in batteryConsumedAppList)
+{
+    Log.Info(LOGTAG, "AppId: " + record.AppId);
+    Log.Info(LOGTAG, "Consumption: " + record.Consumption);
+}
+</pre>
+       </li>
+</ol>
+
+<script type="text/javascript" src="../scripts/jquery.zclip.min.js"></script>
+<script type="text/javascript" src="../scripts/showhide.js"></script>
+</div></div></div>
+
+<a class="top sms" href="#"><img src="../images/btn_top.gif" alt="Go to top" /></a>
+
+<div id="footer">
+<p class="footer">Except as noted, this content - excluding the Code Examples - is licensed under <a href="http://creativecommons.org/licenses/by/3.0/legalcode" target="_blank">Creative Commons Attribution 3.0</a> and all of the Code Examples contained herein are licensed under <a href="https://www.tizen.org/bsd-3-clause-license" target="_blank">BSD-3-Clause</a>.<br/>For details, see the <a href="https://www.tizen.org/content-license" target="_blank">Content License</a>.</p>
+</div>
+
+<script type="text/javascript">
+var _gaq = _gaq || [];
+_gaq.push(['_setAccount', 'UA-25976949-1']);
+_gaq.push(['_trackPageview']);
+(function() {
+var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+})();
+</script>
+
+       </body>
+</html>