runtime.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  6. <meta name="HandheldFriendly" content="true">
  7. <meta name="MobileOptimized" content="320">
  8. <title>Runtime Document</title>
  9. <link rel="stylesheet" type="text/css" href="res/doc.css" charset="utf-8">
  10. <link rel="stylesheet" type="text/css" href="res/prettify.sons.css" charset="utf-8">
  11. <script type="text/javascript" src="res/doc.js" charset="utf-8"></script><script type="text/javascript" src="res/prettify.js" charset="utf-8"></script>
  12. </head>
  13. <body><div id="content" class="content">
  14. <h1><a name="plus.runtime">runtime</a></h1>
  15. <p>Runtime模块管理运行环境,可用于获取当前运行环境信息、与其它程序进行通讯等。通过plus.runtime可获取运行环境管理对象。</p>
  16. <h2>属性:</h2>
  17. <ul>
  18. <li>
  19. <a href="#plus.runtime.appid">appid</a>: 当前应用的APPID</li>
  20. <li>
  21. <a href="#plus.runtime.arguments">arguments</a>: 第三方程序调用时传递给程序的参数</li>
  22. <li>
  23. <a href="#plus.runtime.channel">channel</a>: 应用的渠道标识</li>
  24. <li>
  25. <a href="#plus.runtime.launcher">launcher</a>: 应用启动来源</li>
  26. <li>
  27. <a href="#plus.runtime.origin">origin</a>: 应用安装来源</li>
  28. <li>
  29. <a href="#plus.runtime.version">version</a>: 客户端的版本名称</li>
  30. <li>
  31. <a href="#plus.runtime.versionCode">versionCode</a>: 客户端的版本号</li>
  32. <li>
  33. <a href="#plus.runtime.innerVersion">innerVersion</a>: 客户端5+运行环境的内部版本号</li>
  34. <li>
  35. <a href="#plus.runtime.uniVersion">uniVersion</a>: 客户端uni-app运行环境的版本号</li>
  36. <li>
  37. <a href="#plus.runtime.launchLoadedTime">launchLoadedTime</a>: 获取当前应用首页加载的时间</li>
  38. <li>
  39. <a href="#plus.runtime.processId">processId</a>: 获取当前应用的进程标识</li>
  40. <li>
  41. <a href="#plus.runtime.startupTime">startupTime</a>: 获取当前应用的启动时间戳</li>
  42. <li>
  43. <a href="#plus.runtime.isRecovery">isRecovery</a>: 应用是否由于内核崩溃自动恢复</li>
  44. </ul>
  45. <h2>方法:</h2>
  46. <ul>
  47. <li>
  48. <a href="#plus.runtime.getProperty">getProperty</a>: 获取指定APPID对应的应用信息</li>
  49. <li>
  50. <a href="#plus.runtime.install">install</a>: 安装应用</li>
  51. <li>
  52. <a href="#plus.runtime.quit">quit</a>: 退出应用</li>
  53. <li>
  54. <a href="#plus.runtime.restart">restart</a>: 重启当前的应用</li>
  55. <li>
  56. <a href="#plus.runtime.setBadgeNumber">setBadgeNumber</a>: 设置程序快捷方式图标上显示的角标数字</li>
  57. <li>
  58. <a href="#plus.runtime.openURL">openURL</a>: 调用第三方程序打开指定的URL</li>
  59. <li>
  60. <a href="#plus.runtime.openWeb">openWeb</a>: 使用内置Webview窗口打开URL</li>
  61. <li>
  62. <a href="#plus.runtime.openFile">openFile</a>: 调用第三方程序打开指定的文件</li>
  63. <li>
  64. <a href="#plus.runtime.processDirectPage">processDirectPage</a>: 处理直达页面链接参数</li>
  65. <li>
  66. <a href="#plus.runtime.launchApplication">launchApplication</a>: 调用第三方程序</li>
  67. <li>
  68. <a href="#plus.runtime.isApplicationExist">isApplicationExist</a>: 判断第三方程序是否已存在</li>
  69. <li>
  70. <a href="#plus.runtime.isCustomLaunchPath">isCustomLaunchPath</a>: 判断是否自定义应用启动页面加载地址</li>
  71. </ul>
  72. <h2>对象:</h2>
  73. <ul>
  74. <li>
  75. <a href="#plus.runtime.ApplicationInf">ApplicationInf</a>: JSON对象,打开第三方程序参数</li>
  76. <li>
  77. <a href="#plus.runtime.BadgeOptions">BadgeOptions</a>: JSON对象,应用角标显示需要的通知栏消息的参数</li>
  78. <li>
  79. <a href="#plus.runtime.OpenFileOptions">OpenFileOptions</a>: JSON对象,打开文件参数</li>
  80. <li>
  81. <a href="#plus.runtime.WidgetInfo">WidgetInfo</a>: JSON对象,应用信息</li>
  82. <li>
  83. <a href="#plus.runtime.WidgetOptions">WidgetOptions</a>: JSON对象,应用安装参数</li>
  84. </ul>
  85. <h2>回调方法:</h2>
  86. <ul>
  87. <li>
  88. <a href="#plus.runtime.InstallSuccessCallback">InstallSuccessCallback</a>: 安装应用成功回调函数</li>
  89. <li>
  90. <a href="#plus.runtime.InstallErrorCallback">InstallErrorCallback</a>: 安装应用失败回调函数</li>
  91. <li>
  92. <a href="#plus.runtime.GetPropertyCallBack">GetPropertyCallBack</a>: 获取应用属性成功回调函数</li>
  93. <li>
  94. <a href="#plus.runtime.OpenErrorCallback">OpenErrorCallback</a>: 打开本地文件或URL失败回调函数</li>
  95. <li>
  96. <a href="#plus.runtime.LaunchErrorCallback">LaunchErrorCallback</a>: 调用第三方程序失败回调函数</li>
  97. </ul>
  98. <h2>权限:</h2>
  99. <p>5+功能模块(permissions)</p>
  100. <pre class="prettyprint linenums">
  101. {
  102. // ...
  103. "permissions":{
  104. // ...
  105. "Runtime": {
  106. "description": "运行环境"
  107. }
  108. }
  109. }
  110. </pre>
  111. <h1><a name="plus.runtime.ApplicationInf">ApplicationInf</a></h1>
  112. <p>JSON对象,打开第三方程序参数</p>
  113. <h2>属性:</h2>
  114. <ul>
  115. <li>pname: <em>(<font class="type">String</font>
  116. 类型
  117. )</em>第三方程序包名<br><p>仅Android平台支持,表示程序的包名,其它平台忽略此属性值。</p>
  118. </li>
  119. <li>action: <em>(<font class="type">String</font>
  120. 类型
  121. )</em>程序的操作行为<br><p>Android平台上与系统的action值一致;iOS平台为要调用程序的URLScheme格式字符串。</p>
  122. </li>
  123. <li>newTask: <em>(<font class="type">Boolean</font>
  124. 类型
  125. )</em>新任务模式标记<br><p>
  126. 可取值:
  127. true-使用新任务模式标记(FLAG_ACTIVITY_NEW_TASK)启动应用;
  128. false-不使用新任务模式标记(FLAG_ACTIVITY_NEW_TASK)启动应用。
  129. 默认值为true。
  130. 注意:由于5+应用配置的launchMode为singleTask,所以另一个5+应用通过plus.runtime.launchApplication启动时如果应用已经在后台运行则不会触发newintent事件,为了避免此问题需要将newTask参数值设置为false。
  131. </p>
  132. </li>
  133. <li>extra: <em>(<font class="type">JSON</font>
  134. 类型
  135. )</em>调用程序的参数<br><p>仅Android平台支持,为JSON格式,用于传递给要调用程序的参数,如extra:{url:"http://www.html5plus.org"}。</p>
  136. </li>
  137. </ul>
  138. <h1><a name="plus.runtime.BadgeOptions">BadgeOptions</a></h1>
  139. <p>JSON对象,应用角标显示需要的通知栏消息的参数</p>
  140. <h2>属性:</h2>
  141. <ul>
  142. <li>title: <em>(<font class="type">String</font>
  143. 类型
  144. )</em>消息的标题<br><p>
  145. 默认值为应用的名称。
  146. </p>
  147. </li>
  148. <li>content: <em>(<font class="type">String</font>
  149. 类型
  150. )</em>消息的内容<br><p>
  151. 默认值为“您有x条未读消息"”,其中x未设置的角标数字值。
  152. </p>
  153. </li>
  154. </ul>
  155. <h1><a name="plus.runtime.OpenFileOptions">OpenFileOptions</a></h1>
  156. <p>JSON对象,打开文件参数</p>
  157. <h2>属性:</h2>
  158. <ul>
  159. <li>pname: <em>(<font class="type">String</font>
  160. 类型
  161. )</em>优先使用的程序包名<br><p>
  162. 如果指定包名的程序已经安装,则调用其打开文件,若程序不支持打开文件则触发错误回调。
  163. 如果指定包名的程序未安装,则弹出系统支持打开此文件的列表,由用户选择程序打开。
  164. </p>
  165. </li>
  166. <li>popover: <em>(<font class="type">json</font>
  167. 类型
  168. )</em>弹出系统选择程序界面指示区域<br><p>
  169. JSON对象,格式如{top:10;left:10;width:200;height:200;},所有值为像素值,左上坐标相对于容器webview的位置。仅在iPad设备平台有效。
  170. </p>
  171. </li>
  172. </ul>
  173. <h1><a name="plus.runtime.WidgetInfo">WidgetInfo</a></h1>
  174. <p>JSON对象,应用信息</p>
  175. <h2>属性:</h2>
  176. <ul>
  177. <li>appid: <em>(<font class="type">String</font>
  178. 类型
  179. )</em>应用的APPID<br><p>
  180. 对应manifest.json中的id字段值。
  181. </p>
  182. </li>
  183. <li>version: <em>(<font class="type">String</font>
  184. 类型
  185. )</em>应用的版本名称<br><p>
  186. 对应manifest.json中的version-&gt;name字段值。
  187. </p>
  188. </li>
  189. <li>versionCode: <em>(<font class="type">String</font>
  190. 类型
  191. )</em>应用的版本号<br><p>
  192. 对应manifest.json中的version-&gt;code字段值。
  193. </p>
  194. </li>
  195. <li>name: <em>(<font class="type">String</font>
  196. 类型
  197. )</em>应用的名称<br><p>
  198. 对应manifest.json中的name字段值。
  199. </p>
  200. </li>
  201. <li>description: <em>(<font class="type">String</font>
  202. 类型
  203. )</em>应用描述信息<br><p>
  204. 对应manifest.json中的description字段值。
  205. </p>
  206. </li>
  207. <li>author: <em>(<font class="type">String</font>
  208. 类型
  209. )</em>应用描述信息<br><p>
  210. 对应manifest.json中的developer-&gt;name字段值。
  211. </p>
  212. </li>
  213. <li>email: <em>(<font class="type">String</font>
  214. 类型
  215. )</em>开发者邮箱地址<br><p>
  216. 对应manifest.json中的developer-&gt;email字段值。
  217. </p>
  218. </li>
  219. <li>features: <em>(<font class="type">String[]</font>
  220. 类型
  221. )</em>应用许可特性列表<br><p>
  222. 对应manifest.json中的permissions字段下所有键名的列表。
  223. </p>
  224. </li>
  225. </ul>
  226. <h1><a name="plus.runtime.WidgetOptions">WidgetOptions</a></h1>
  227. <p>JSON对象,应用安装参数</p>
  228. <h2>说明:</h2>
  229. <p class="des">可通过对象设置安装的应用是否进行appid校验、版本号校验等。</p>
  230. <h2>属性:</h2>
  231. <ul><li>force: <em>(<font class="type">Boolean</font>
  232. 类型
  233. )</em>是否强制安装<br><p>
  234. true表示强制安装,不进行版本号的校验;false则需要版本号校验,如果将要安装应用的版本号不高于现有应用的版本号则终止安装,并返回安装失败。
  235. 仅安装wgt和wgtu时生效,默认值 false。
  236. </p>
  237. </li></ul>
  238. <h1><a name="plus.runtime.InstallSuccessCallback">InstallSuccessCallback</a></h1>
  239. <p>安装应用成功回调函数</p>
  240. <pre class="prettyprint linenums">
  241. void onSuccess(widgetInfo){
  242. // Code here
  243. }
  244. </pre>
  245. <h2>参数:</h2>
  246. <ul><li>widgetInfo:
  247. <em>(
  248. <font class="type">WidgetInfo</font>
  249. )
  250. 必选 </em><br>应用信息,参见:WidgetInfo</li></ul>
  251. <h2>返回值:</h2>
  252. <font class="type">void</font>
  253. : 无<h1><a name="plus.runtime.InstallErrorCallback">InstallErrorCallback</a></h1>
  254. <p>安装应用失败回调函数</p>
  255. <pre class="prettyprint linenums">
  256. void onError(error){
  257. // Handle the error
  258. }
  259. </pre>
  260. <h2>参数:</h2>
  261. <ul><li>error:
  262. <em>(
  263. <font class="type">DOMException</font>
  264. )
  265. 必选 </em><br>安装失败的错误信息</li></ul>
  266. <h2>返回值:</h2>
  267. <font class="type">void</font>
  268. : 无<h1><a name="plus.runtime.GetPropertyCallBack">GetPropertyCallBack</a></h1>
  269. <p>获取应用属性成功回调函数</p>
  270. <pre class="prettyprint linenums">
  271. void onGetPropertyCB(widgetInfo){
  272. // Code here
  273. }
  274. </pre>
  275. <h2>参数:</h2>
  276. <ul><li>widgetInfo:
  277. <em>(
  278. <a href="#plus.runtime.WidgetInfo">WidgetInfo</a>
  279. )
  280. 必选 </em>应用信息<br>
  281. 包括应用名称、标识等属性。
  282. </li></ul>
  283. <h2>返回值:</h2>
  284. <font class="type">void</font>
  285. : 无<h1><a name="plus.runtime.OpenErrorCallback">OpenErrorCallback</a></h1>
  286. <p>打开本地文件或URL失败回调函数</p>
  287. <pre class="prettyprint linenums">
  288. void onError(error){
  289. // Handle the error
  290. }
  291. </pre>
  292. <h2>参数:</h2>
  293. <ul><li>error:
  294. <em>(
  295. <font class="type">DOMException</font>
  296. )
  297. 必选 </em><br>打开操作失败的错误信息</li></ul>
  298. <h2>返回值:</h2>
  299. <font class="type">void</font>
  300. : 无<h1><a name="plus.runtime.LaunchErrorCallback">LaunchErrorCallback</a></h1>
  301. <p>调用第三方程序失败回调函数</p>
  302. <pre class="prettyprint linenums">
  303. void onError(error){
  304. // Handle the error
  305. }
  306. </pre>
  307. <h2>参数:</h2>
  308. <ul><li>error:
  309. <em>(
  310. <font class="type">DOMException</font>
  311. )
  312. 必选 </em>操作失败的错误信息<br>
  313. 可通过error.code(Number类型)获取错误编码;
  314. 可通过error.message(String类型)获取错误描述信息。
  315. </li></ul>
  316. <h2>返回值:</h2>
  317. <font class="type">void</font>
  318. : 无<br><br>
  319. </div></body>
  320. </html>