Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
4226e9a8
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
4226e9a8
编写于
3月 17, 2022
作者:
O
openharmony_ci
提交者:
Gitee
3月 17, 2022
浏览文件
操作
浏览文件
下载
差异文件
!2105 修复ability资料说明
Merge pull request !2105 from guyuanzhang/fa_docs
上级
212329ab
5d61d1f3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
93 addition
and
60 deletion
+93
-60
zh-cn/application-dev/ability/ability-assistant-guidelines.md
...n/application-dev/ability/ability-assistant-guidelines.md
+1
-1
zh-cn/application-dev/ability/fa-brief.md
zh-cn/application-dev/ability/fa-brief.md
+21
-1
zh-cn/application-dev/ability/fa-pageability.md
zh-cn/application-dev/ability/fa-pageability.md
+71
-58
zh-cn/application-dev/ability/figures/fa-package-info.png
zh-cn/application-dev/ability/figures/fa-package-info.png
+0
-0
zh-cn/application-dev/ability/figures/fa-pageAbility-lifecycle.png
...lication-dev/ability/figures/fa-pageAbility-lifecycle.png
+0
-0
zh-cn/application-dev/ability/figures/fa-threading-model.png
zh-cn/application-dev/ability/figures/fa-threading-model.png
+0
-0
未找到文件。
zh-cn/application-dev/ability/ability-assistant-guidelines.md
浏览文件 @
4226e9a8
...
...
@@ -78,7 +78,7 @@ Ability assistant(Ability助手,简称为aa)是实现应用、原子化服
| -s/--stack
\<
number> | 打印指定mission stack内的Ability。 |
| -m/--mission
\<
number> | 打印指定mission内的Ability。 |
| -l/--stack-list | 打印每个mission stack内的mission列表。 |
| -u/--ui | 打印system
ui
Ability。 |
| -u/--ui | 打印system
UI
Ability。 |
| -e/--serv | 打印Service Ability。 |
| -d/--data | 打印Data Ability。 |
...
...
zh-cn/application-dev/ability/fa-brief.md
浏览文件 @
4226e9a8
# FA模型综述
\ No newline at end of file
# FA模型综述
## 整体架构
鸿蒙用户程序的开发本质上就是开发Ability,OpenHarmony系统也是通过调度Ability,通过系统提供的一致性调度契约对Ability进行生命周期管理,从而实现对用户程序的调度。FA模型中Ability分为PageAbility、ServiceAbility和DataAbility三种类型。其中PageAbility具备ArkUI的Ability,是用户具体可见并可以交互的Ability实例;ServiceAbility也是Ability一种,但是没有UI,提供其他Ability调用自定义的服务,在后台运行;DataAbility也是没有UI,提供其他Ability进行数据的增删查服务,在后台运行。
## 应用包结构
**应用包结构如下图所示:**
![
fa-package-info
](
figures/fa-package-info.png
)
## 生命周期
**pageAbility生命周期回调如下图所示:**
![
fa-pageAbility-lifecycle
](
figures/fa-pageAbility-lifecycle.png
)
开发者可以在 app.js/app.ets 中重写生命周期函数,在对应的生命周期函数内处理应用相应逻辑。
## 进程线程模型
应用独享独立进程,Ability独享独立线程,应用进程在Ability第一次启动时创建,并为启动的Ability创建线程,应启动后再启动应用内其他Ability,会创建相应的线程。每个Ability独享一个JSRuntime,因此Ability之间是隔离的。
![
fa-threading-nodel
](
figures/fa-threading-model.png
)
\ No newline at end of file
zh-cn/application-dev/ability/fa-pageability.md
浏览文件 @
4226e9a8
...
...
@@ -27,19 +27,19 @@ Page模板(以下简称“Page”)是FA唯一支持的模板,用于提供
**PageAbility类型Ability生命周期回调如下图所示:**
![
PageAbility-Lifecycel-Callbacks
](
figures/page-ability-lifecycle-callbacks
.png
)
![
fa-pageAbility-lifecycle
](
figures/fa-pageAbility-lifecycle
.png
)
## 启动本地PageAbility
导入模块
*
导入模块
```
import featureAbility from '@ohos.ability.featureAbility'
```
```
F
eatureAbility.startAbility(parameter: StartAbilityParameter, callback: AsyncCallback<number>)
f
eatureAbility.startAbility(parameter: StartAbilityParameter, callback: AsyncCallback<number>)
```
*
接口说明
...
...
@@ -50,61 +50,75 @@ import featureAbility from '@ohos.ability.featureAbility'
```
javascript
import
featureAbility
from
'
@ohos.ability.featureAbility
'
featureAbility
.
startAbility
(
{
want
:
{
action
:
""
,
entities
:
[
""
],
type
:
""
,
options
:
{
// indicates the grant to perform read operations on the URI
authReadUriPermission
:
true
,
// indicates the grant to perform write operations on the URI
authWriteUriPermission
:
true
,
// support forward intent result to origin ability
abilityForwardResult
:
true
,
// used for marking the ability start-up is triggered by continuation
abilityContinuation
:
true
,
// specifies whether a component does not belong to ohos
notOhosComponent
:
true
,
// specifies whether an ability is started
abilityFormEnabled
:
true
,
// indicates the grant for possible persisting on the URI.
authPersistableUriPermission
:
true
,
// indicates the grant for possible persisting on the URI.
authPrefixUriPermission
:
true
,
// support distributed scheduling system start up multiple devices
abilitySliceMultiDevice
:
true
,
// indicates that an ability using the service template is started regardless of whether the
// host application has been started.
startForegroundAbility
:
true
,
// install the specified ability if it's not installed.
installOnDemand
:
true
,
// return result to origin ability slice
abilitySliceForwardResult
:
true
,
// install the specified ability with background mode if it's not installed.
installWithBackgroundMode
:
true
},
deviceId
:
""
,
bundleName
:
"
com.example.startability
"
,
abilityName
:
"
com.example.startability.MainAbility
"
,
uri
:
""
},
featureAbility
.
startAbility
({
want
:
{
action
:
""
,
entities
:
[
""
],
type
:
""
,
options
:
{
// indicates the grant to perform read operations on the URI
authReadUriPermission
:
true
,
// indicates the grant to perform write operations on the URI
authWriteUriPermission
:
true
,
// support forward intent result to origin ability
abilityForwardResult
:
true
,
// used for marking the ability start-up is triggered by continuation
abilityContinuation
:
true
,
// specifies whether a component does not belong to ohos
notOhosComponent
:
true
,
// specifies whether an ability is started
abilityFormEnabled
:
true
,
// indicates the grant for possible persisting on the URI.
authPersistableUriPermission
:
true
,
// indicates the grant for possible persisting on the URI.
authPrefixUriPermission
:
true
,
// support distributed scheduling system start up multiple devices
abilitySliceMultiDevice
:
true
,
// indicates that an ability using the service template is started regardless of whether the
// host application has been started.
startForegroundAbility
:
true
,
// install the specified ability if it's not installed.
installOnDemand
:
true
,
// return result to origin ability slice
abilitySliceForwardResult
:
true
,
// install the specified ability with background mode if it's not installed.
installWithBackgroundMode
:
true
},
);
)
deviceId
:
""
,
bundleName
:
"
com.example.startability
"
,
abilityName
:
"
com.example.startability.MainAbility
"
,
uri
:
""
},
},
);
```
want参数也可以使用parameters参数,使用key-value的方式输入。
*
示例
```
javascript
import
featureAbility
from
'
@ohos.ability.featureAbility
'
featureAbility
.
startAbility
({
want
:
{
bundleName
:
"
com.example.startability
"
,
uri
:
""
,
parameters
:
{
abilityName
:
"
com.example.startability.MainAbility
"
}
},
},
);
```
## 启动远程PageAbility
导入模块
*
导入模块
```
import featureAbility from '@ohos.ability.featureAbility'
```
```
F
eatureAbility.startAbility(parameter: StartAbilityParameter)
f
eatureAbility.startAbility(parameter: StartAbilityParameter)
```
*
接口说明
...
...
@@ -114,14 +128,13 @@ FeatureAbility.startAbility(parameter: StartAbilityParameter)
*
示例
```
javascript
var
promise
=
await
ability
.
startAbility
(
{
want
:
{
deviceId
:
this
.
deviceId
,
bundleName
:
"
com.example.test
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
},
}
);
var
promise
=
await
featureAbility
.
startAbility
({
want
:
{
deviceId
:
this
.
deviceId
,
bundleName
:
"
com.example.test
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
},
}
);
```
\ No newline at end of file
zh-cn/application-dev/ability/figures/fa-package-info.png
0 → 100755
浏览文件 @
4226e9a8
35.8 KB
zh-cn/application-dev/ability/figures/fa-pageAbility-lifecycle.png
0 → 100755
浏览文件 @
4226e9a8
24.6 KB
zh-cn/application-dev/ability/figures/fa-threading-model.png
0 → 100755
浏览文件 @
4226e9a8
49.5 KB
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录