Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
f6cb200c
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f6cb200c
编写于
12月 24, 2022
作者:
zyjhandsome
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://gitee.com/openharmony/docs
上级
ed20beb8
3ba9bc40
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
483 addition
and
207 deletion
+483
-207
zh-cn/application-dev/device/inputdevice-guidelines.md
zh-cn/application-dev/device/inputdevice-guidelines.md
+3
-3
zh-cn/application-dev/device/pointerstyle-guidelines.md
zh-cn/application-dev/device/pointerstyle-guidelines.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md
...ation-dev/reference/apis/js-apis-app-ability-wantAgent.md
+3
-7
zh-cn/application-dev/reference/apis/js-apis-inner-application-appStateData.md
.../reference/apis/js-apis-inner-application-appStateData.md
+23
-16
zh-cn/application-dev/reference/apis/js-apis-inner-application-baseContext.md
...v/reference/apis/js-apis-inner-application-baseContext.md
+4
-4
zh-cn/application-dev/reference/apis/js-apis-inner-application-context.md
...n-dev/reference/apis/js-apis-inner-application-context.md
+62
-16
zh-cn/application-dev/reference/apis/js-apis-inner-application-continueCallback.md
...erence/apis/js-apis-inner-application-continueCallback.md
+26
-17
zh-cn/application-dev/reference/apis/js-apis-inner-application-continueDeviceInfo.md
...ence/apis/js-apis-inner-application-continueDeviceInfo.md
+15
-14
zh-cn/application-dev/reference/apis/js-apis-inner-application-errorObserver.md
...reference/apis/js-apis-inner-application-errorObserver.md
+12
-6
zh-cn/application-dev/reference/apis/js-apis-inner-application-eventHub.md
...-dev/reference/apis/js-apis-inner-application-eventHub.md
+80
-73
zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionContext.md
...erence/apis/js-apis-inner-application-extensionContext.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionRunningInfo.md
...ce/apis/js-apis-inner-application-extensionRunningInfo.md
+32
-24
zh-cn/application-dev/reference/apis/js-apis-inner-wantAgent-triggerInfo.md
...dev/reference/apis/js-apis-inner-wantAgent-triggerInfo.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-mouseevent.md
zh-cn/application-dev/reference/apis/js-apis-mouseevent.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-pointer.md
zh-cn/application-dev/reference/apis/js-apis-pointer.md
+4
-4
zh-cn/application-dev/reference/apis/js-apis-wantAgent.md
zh-cn/application-dev/reference/apis/js-apis-wantAgent.md
+18
-18
zh-cn/release-notes/changelogs/OpenHarmony_3.2.8.1/changelogs-inputmethod-framworks.md
...s/OpenHarmony_3.2.8.1/changelogs-inputmethod-framworks.md
+196
-0
未找到文件。
zh-cn/application-dev/device/inputdevice-guidelines.md
浏览文件 @
f6cb200c
...
...
@@ -40,8 +40,8 @@ try {
// 1.获取设备列表,判断是否有物理键盘连接
inputDevice
.
getDeviceList
().
then
(
data
=>
{
for
(
let
i
=
0
;
i
<
data
.
length
;
++
i
)
{
inputDevice
.
getKeyboardType
(
data
[
i
]).
then
(
res
=>
{
if
(
type
==
inputDevice
.
KeyboardType
.
ALPHABETIC_KEYBOARD
)
{
inputDevice
.
getKeyboardType
(
data
[
i
]).
then
(
type
=>
{
if
(
type
==
=
inputDevice
.
KeyboardType
.
ALPHABETIC_KEYBOARD
)
{
// 物理键盘已连接
isPhysicalKeyboardExist
=
true
;
}
...
...
@@ -53,7 +53,7 @@ try {
console
.
log
(
`Device event info:
${
JSON
.
stringify
(
data
)}
`
);
inputDevice
.
getKeyboardType
(
data
.
deviceId
,
(
error
,
type
)
=>
{
console
.
log
(
"
The keyboard type is:
"
+
type
);
if
(
type
==
inputDevice
.
KeyboardType
.
ALPHABETIC_KEYBOARD
&&
data
.
type
==
'
add
'
)
{
if
(
type
==
=
inputDevice
.
KeyboardType
.
ALPHABETIC_KEYBOARD
&&
data
.
type
==
'
add
'
)
{
// 物理键盘已插入
isPhysicalKeyboardExist
=
true
;
}
else
if
(
type
==
inputDevice
.
KeyboardType
.
ALPHABETIC_KEYBOARD
&&
data
.
type
==
'
remove
'
)
{
...
...
zh-cn/application-dev/device/pointerstyle-guidelines.md
浏览文件 @
f6cb200c
...
...
@@ -7,7 +7,7 @@
## 导入模块
```
js
import
inputDevice
from
'
@ohos.multimodalInput.pointer
'
;
import
pointer
from
'
@ohos.multimodalInput.pointer
'
;
```
## 接口说明
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md
浏览文件 @
f6cb200c
# @ohos.app.ability.wantAgent (WantAgent模块)
app.ability.WantAgent模块提供了
触发、取消、比较WantAgent实例和获取bundle名称的能力,包括创建WantAgent实例、获取实例的用户ID、获取want信息等
。该模块将会取代
[
@ohos.wantAgent
](
js-apis-wantAgent.md
)
模块,建议优先使用本模块。
app.ability.WantAgent模块提供了
创建WantAgent实例、获取实例的用户ID、获取want信息、比较WantAgent实例和获取bundle名称等能力
。该模块将会取代
[
@ohos.wantAgent
](
js-apis-wantAgent.md
)
模块,建议优先使用本模块。
> **说明:**
>
...
...
@@ -1042,10 +1042,6 @@ try{
}
```
//TODO WantAgent.trigger Callback
## WantAgent.trigger
trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback
\<
CompleteData
\>
): void
...
...
@@ -1059,7 +1055,7 @@ trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback\<Co
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ----------------------------- | ---- | ------------------------------- |
| agent | WantAgent | 是 | WantAgent对象。 |
| triggerInfo |
TriggerInfo
| 是 | TriggerInfo对象。 |
| triggerInfo |
[
TriggerInfo
](
js-apis-inner-wantAgent-triggerInfo.md
)
| 是 | TriggerInfo对象。 |
| callback | AsyncCallback
\<
CompleteData
\>
| 否 | 主动激发WantAgent实例的回调方法。 |
**错误码:**
...
...
@@ -1096,7 +1092,7 @@ trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback\<Co
var
wantAgent
;
// triggerInfo
var
triggerInfo
=
{
code
:
0
code
:
0
//自定义义结果码
}
//WantAgentInfo对象
var
wantAgentInfo
=
{
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-appStateData.md
浏览文件 @
f6cb200c
...
...
@@ -4,25 +4,32 @@
**系统能力**
:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
**系统API**
:
该接口为系统接口,三方应用不支持调用。
**系统API**
:
本模块被标记为@systemapi,对三方应用隐藏
| 名称
| 类型 | 必填 | 说明
|
| -----------
| -------- | ---- | ---------------------------------------------------
--------- |
| bundleName
<sup>
8+
</sup>
| string | 否 | 包名。
|
| uid
<sup>
8+
</sup>
| number | 否 | 用户ID。
|
| state
<sup>
8+
</sup>
| number | 否 | 应用状态。
|
| 名称
| 类型 | 必填 | 说明
|
| -----------
-------------- | ------ | ---- |
--------- |
| bundleName
<sup>
8+
</sup>
| string | 否 | 包名。
|
| uid
<sup>
8+
</sup>
| number | 否 | 应用程序的uid。
|
| state
<sup>
8+
</sup>
| number | 否 | 应用状态。
<br>
0:初始化状态,应用正在初始化
<br>
1:就绪状态,应用已初始化完毕
<br>
2:前台状态,应用位于前台
<br>
3:获焦状态。(预留状态,当前暂不支持)
<br>
4:后台状态,应用位于后台
<br>
5:退出状态,应用已退出
|
**示例:**
```
ts
import
appManager
from
"
@ohos.app
lication
.appManager
"
import
appManager
from
"
@ohos.app
.ability
.appManager
"
appManager
.
getForegroundApplications
((
error
,
data
)
=>
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
let
appStateData
=
data
[
i
];
console
.
info
(
'
appStateData.bundleName:
'
+
appStateData
.
bundleName
);
console
.
info
(
'
appStateData.uid:
'
+
appStateData
.
uid
);
console
.
info
(
'
appStateData.state:
'
+
appStateData
.
state
);
}
});
function
getForegroundAppInfos
()
{
appManager
.
getForegroundApplications
((
error
,
data
)
=>
{
if
(
error
&&
error
.
code
)
{
console
.
log
(
'
getForegroundApplications failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
return
;
}
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
let
appStateData
=
data
[
i
];
console
.
log
(
'
appStateData.bundleName:
'
+
appStateData
.
bundleName
);
console
.
log
(
'
appStateData.uid:
'
+
appStateData
.
uid
);
console
.
log
(
'
appStateData.state:
'
+
appStateData
.
state
);
}
});
}
```
zh-cn/application-dev/reference/apis/js-apis-inner-application-baseContext.md
浏览文件 @
f6cb200c
...
...
@@ -3,21 +3,21 @@
BaseContext抽象类用于表示继承的子类Context是Stage模型还是FA模型。
> **说明:**
>
>
> 本模块首批接口从API version 8 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | ------ | ---- | ---- | ------- |
| stageMode | boolean | 是 | 是 | 表示
Stage模型还是
FA模型。 |
| stageMode | boolean | 是 | 是 | 表示
是否Stage模型。
<br>
true:Stage模型
<br>
false:
FA模型。 |
**示例:**
```
ts
class
MyContext
extends
BaseContext
{
constructor
(
stageMode
)
{
this
.
stageMode
=
stageMode
;
}
}
```
\ No newline at end of file
```
zh-cn/application-dev/reference/apis/js-apis-inner-application-context.md
浏览文件 @
f6cb200c
# Context
模块
# Context
Context模块提供了ability或application的上下文的能力,包括访问特定应用程序的资源等。
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块接口仅可在Stage模型下使用。
>
-
本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
-
本模块接口仅可在Stage模型下使用。
## 属性
...
...
@@ -25,12 +25,13 @@ Context模块提供了ability或application的上下文的能力,包括访问
| eventHub | string | 是 | 否 | 事件中心,提供订阅、取消订阅、触发事件对象。 |
| area |
[
AreaMode
](
#areamode
)
| 是 | 否 | 文件分区信息。 |
## Context.createBundleContext
createBundleContext(bundleName: string): Context;
根据包名创建安装包的上下文Context。
根据包名创建安装包的上下文。
**需要权限**
: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
...
...
@@ -44,19 +45,32 @@ createBundleContext(bundleName: string): Context;
| 类型 | 说明 |
| -------- | -------- |
| Context | 安装包的上下文Context。 |
| Context | 安装包的上下文。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
其他ID见
[
元能力子系统错误码
](
../errorcodes/errorcode-ability.md
)
**示例:**
```
ts
let
bundleContext
=
this
.
context
.
createBundleContext
(
"
com.example.test
"
);
let
bundleContext
;
try
{
bundleContext
=
this
.
context
.
createBundleContext
(
"
com.example.test
"
);
}
catch
(
error
)
{
console
.
log
(
'
createBundleContext failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
}
```
## Context.createModuleContext
createModuleContext(moduleName: string): Context;
根据模块名创建上下文
Context
。
根据模块名创建上下文。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
...
...
@@ -70,17 +84,30 @@ createModuleContext(moduleName: string): Context;
| 类型 | 说明 |
| -------- | -------- |
| Context | 上下文Context。 |
| Context | 模块的上下文。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
其他ID见
[
元能力子系统错误码
](
../errorcodes/errorcode-ability.md
)
**示例:**
```
ts
let
moduleContext
=
this
.
context
.
createModuleContext
(
"
entry
"
);
let
moduleContext
;
try
{
moduleContext
=
this
.
context
.
createModuleContext
(
"
entry
"
);
}
catch
(
error
)
{
console
.
log
(
'
createModuleContext failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
}
```
createModuleContext(bundleName: string, moduleName: string): Context;
根据包名和模块名创建上下文
Context
。
根据包名和模块名创建上下文。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
...
...
@@ -95,19 +122,32 @@ createModuleContext(bundleName: string, moduleName: string): Context;
| 类型 | 说明 |
| -------- | -------- |
| Context | 上下文Context。 |
| Context | 模块的上下文。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
其他ID见
[
元能力子系统错误码
](
../errorcodes/errorcode-ability.md
)
**示例:**
```
ts
let
moduleContext
=
this
.
context
.
createModuleContext
(
"
com.example.test
"
,
"
entry
"
);
let
moduleContext
;
try
{
moduleContext
=
this
.
context
.
createModuleContext
(
"
com.example.test
"
,
"
entry
"
);
}
catch
(
error
)
{
console
.
log
(
'
createModuleContext failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
}
```
## Context.getApplicationContext
getApplicationContext(): ApplicationContext;
获取
应用上下文Context
。
获取
本应用的应用上下文
。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
...
...
@@ -115,12 +155,18 @@ getApplicationContext(): ApplicationContext;
| 类型 | 说明 |
| -------- | -------- |
|
Context
| 应用上下文Context。 |
|
[
ApplicationContext
](
js-apis-inner-application-applicationContext.md
)
| 应用上下文Context。 |
**示例:**
```
ts
let
applicationContext
=
this
.
context
.
getApplicationContext
();
let
applicationContext
;
try
{
applicationContext
=
this
.
context
.
getApplicationContext
();
}
catch
(
error
)
{
console
.
log
(
'
getApplicationContext failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
}
```
## AreaMode
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-continueCallback.md
浏览文件 @
f6cb200c
# ContinueCallback
表示迁移完成后,返回迁移结果回调函数,可以作为
[
continueMission
](
js-apis-distributedMissionManager.md#distributedmissionmanagercontinuemission
)
的入参监听迁移回调。
表示跨设备迁移Mission完成后,返回迁移结果的回调函数,迁移Mission详见:
[
continueMission接口
](
js-apis-distributedMissionManager.md#distributedmissionmanagercontinuemission
)
。
## ContinueCallback.onContinueDone
onContinueDone(result: number): void;
Mission迁移完成后调用,返回迁移结果。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Mission
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------------- | -------- | ---- | ---- | ------------------ |
| onContinueDone | function | 是 | 否 | 通知迁移完成,返回迁移结果。 |
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| result | number | 否 | 迁移任务的结果。 |
**示例:**
```
ts
import
distributedMissionManager
from
'
@ohos.distributedMissionManager
'
;
import
distributedMissionManager
from
'
@ohos.distributedMissionManager
'
let
continueDeviceInfo
=
{
srcDeviceId
:
"
123
"
,
dstDeviceId
:
"
456
"
,
missionId
:
123
,
wantParam
:
{
"
key
"
:
"
value
"
}
srcDeviceId
:
"
123
"
,
dstDeviceId
:
"
456
"
,
missionId
:
123
,
wantParam
:
{
"
key
"
:
"
value
"
}
};
let
continueCallback
=
{
onContinueDone
(
result
)
{
console
.
log
(
'
onContinueDone, result:
'
+
JSON
.
stringify
(
result
));
}
}
}
;
distributedMissionManager
.
continueMission
(
continueDeviceInfo
,
continueCallback
,
(
error
)
=>
{
if
(
error
.
code
!=
0
)
{
console
.
error
(
'
continueMission failed, cause:
'
+
JSON
.
stringify
(
error
))
}
console
.
info
(
'
continueMission finished
'
)
if
(
error
&&
error
.
code
)
{
console
.
log
(
'
continueMission failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
}
console
.
log
(
'
continueMission finished
'
);
})
```
\ No newline at end of file
```
zh-cn/application-dev/reference/apis/js-apis-inner-application-continueDeviceInfo.md
浏览文件 @
f6cb200c
# ContinueDeviceInfo
表示发起
任务迁移时所需参数的枚举,可以作为
[
continueMission
](
js-apis-distributedMissionManager.md#distributedmissionmanagercontinuemission
)
的入参指定迁移相关参数
。
表示发起
Mission迁移时所需参数的枚举,迁移Mission详见:
[
continueMission接口
](
js-apis-distributedMissionManager.md#distributedmissionmanagercontinuemission
)
。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Mission
...
...
@@ -14,27 +14,28 @@
**示例:**
```
ts
import
distributedMissionManager
from
'
@ohos.distributedMissionManager
'
;
import
distributedMissionManager
from
'
@ohos.distributedMissionManager
'
let
continueDeviceInfo
=
{
srcDeviceId
:
"
123
"
,
dstDeviceId
:
"
456
"
,
missionId
:
123
,
wantParam
:
{
"
key
"
:
"
value
"
}
srcDeviceId
:
"
123
"
,
dstDeviceId
:
"
456
"
,
missionId
:
123
,
wantParam
:
{
"
key
"
:
"
value
"
}
};
let
continueCallback
=
{
onContinueDone
(
result
)
{
console
.
log
(
'
onContinueDone, result:
'
+
JSON
.
stringify
(
result
));
}
}
}
;
distributedMissionManager
.
continueMission
(
continueDeviceInfo
,
continueCallback
,
(
error
)
=>
{
if
(
error
.
code
!=
0
)
{
console
.
error
(
'
continueMission failed, cause:
'
+
JSON
.
stringify
(
error
))
}
console
.
info
(
'
continueMission finished
'
)
if
(
error
&&
error
.
code
)
{
console
.
log
(
'
continueMission failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
}
console
.
log
(
'
continueMission finished
'
);
})
```
\ No newline at end of file
```
zh-cn/application-dev/reference/apis/js-apis-inner-application-errorObserver.md
浏览文件 @
f6cb200c
# ErrorObserver
定义异常监听,可以作为
[
registerErrorObserver
](
js-apis-application-errorManager.md#errormanagerregistererrorobserver
)
的入参监听当前应用发生的异常。
定义异常监听,可以作为
[
ErrorManager.on
](
js-apis-app-ability-errorManager.md#errormanageron
)
的入参监听当前应用发生的异常。
## onUnhandledException
##
ErrorObserver.
onUnhandledException
onUnhandledException(errMsg: string): void;
...
...
@@ -19,12 +19,18 @@ onUnhandledException(errMsg: string): void;
**示例:**
```
ts
import
errorManager
from
'
@ohos.app
lication.errorManager
'
;
import
errorManager
from
'
@ohos.app
.ability.errorManager
'
let
observer
=
{
onUnhandledException
(
errorMsg
)
{
console
.
log
(
'
onUnhandledException, errorMsg:
'
+
JSON
.
stringify
(
errorMsg
)
);
console
.
log
(
'
HXW onUnhandledException, errorMsg:
'
,
errorMsg
);
}
}
errorManager
.
registerErrorObserver
(
observer
)
```
\ No newline at end of file
try
{
errorManager
.
on
(
"
error
"
,
observer
);
}
catch
(
error
)
{
console
.
log
(
'
registerErrorObserver
'
+
'
failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
}
```
zh-cn/application-dev/reference/apis/js-apis-inner-application-eventHub.md
浏览文件 @
f6cb200c
...
...
@@ -3,22 +3,24 @@
EventHub模块提供了事件中心,提供订阅、取消订阅、触发事件的能力。
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块接口仅可在Stage模型下使用。
>
>
-
本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
-
本模块接口仅可在Stage模型下使用。
## 使用说明
在使用eventHub的功能前,需要通过Ability实例的成员变量context获取。
在使用eventHub的功能前,需要通过
UI
Ability实例的成员变量context获取。
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
export
default
class
MainAbility
extends
Ability
{
func1
(){
console
.
log
(
"
func1 is called
"
);
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
export
default
class
MainAbility
extends
UIAbility
{
eventFunc
(){
console
.
log
(
"
eventFunc is called
"
);
}
onForeground
()
{
this
.
context
.
eventHub
.
on
(
"
123
"
,
this
.
func1
);
this
.
context
.
eventHub
.
on
(
"
myEvent
"
,
this
.
eventFunc
);
}
}
```
...
...
@@ -36,36 +38,39 @@ on(event: string, callback: Function): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| event | string | 是 | 事件名称。 |
| callback | Function | 是 | 事件回调,事件触发后
运行
。 |
| callback | Function | 是 | 事件回调,事件触发后
调用
。 |
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
export
default
class
MainAbility
extends
Ability
{
onForeground
()
{
this
.
context
.
eventHub
.
on
(
"
123
"
,
this
.
func1
);
this
.
context
.
eventHub
.
on
(
"
123
"
,
()
=>
{
console
.
log
(
"
call anonymous func 1
"
);
});
// 结果:
// func1 is called
// call anonymous func 1
this
.
context
.
eventHub
.
emit
(
"
123
"
);
}
func1
()
{
console
.
log
(
"
func1 is called
"
);
}
}
```
```
ts
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
export
default
class
MainAbility
extends
UIAbility
{
onForeground
()
{
this
.
context
.
eventHub
.
on
(
"
myEvent
"
,
this
.
eventFunc
);
// 支持使用匿名函数订阅事件
this
.
context
.
eventHub
.
on
(
"
myEvent
"
,
()
=>
{
console
.
log
(
"
call anonymous eventFunc
"
);
});
// 结果:
// eventFunc is called
// call anonymous eventFunc
this
.
context
.
eventHub
.
emit
(
"
myEvent
"
);
}
eventFunc
()
{
console
.
log
(
"
eventFunc is called
"
);
}
}
```
## EventHub.off
off(event: string, callback?: Function): void;
取消订阅指定事件。当callback传值时,取消订阅指定的callback;未传值时,取消订阅该事件下所有callback。
取消订阅指定事件。
-
传入callback:取消指定的callback对指定事件的订阅,当该事件触发后,将不会回调该callback。
-
不传callback:取消所有callback对指定事件的订阅。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
...
...
@@ -77,27 +82,28 @@ off(event: string, callback?: Function): void;
| callback | Function | 否 | 事件回调。如果不传callback,则取消订阅该事件下所有callback。 |
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
export
default
class
MainAbility
extends
Ability
{
onForeground
()
{
this
.
context
.
eventHub
.
on
(
"
123
"
,
this
.
func1
);
this
.
context
.
eventHub
.
off
(
"
123
"
,
this
.
func1
);
//取消订阅func1
this
.
context
.
eventHub
.
on
(
"
123
"
,
this
.
func1
);
this
.
context
.
eventHub
.
on
(
"
123
"
,
this
.
func2
);
this
.
context
.
eventHub
.
off
(
"
123
"
);
//取消订阅func1和func2
}
func1
()
{
console
.
log
(
"
func1 is called
"
);
}
func2
()
{
console
.
log
(
"
func2 is called
"
);
}
}
```
```
ts
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
export
default
class
MainAbility
extends
UIAbility
{
onForeground
()
{
this
.
context
.
eventHub
.
on
(
"
myEvent
"
,
this
.
eventFunc1
);
this
.
context
.
eventHub
.
off
(
"
myEvent
"
,
this
.
eventFunc1
);
// 取消eventFunc1对myEvent事件的订阅
this
.
context
.
eventHub
.
on
(
"
myEvent
"
,
this
.
eventFunc1
);
this
.
context
.
eventHub
.
on
(
"
myEvent
"
,
this
.
eventFunc2
);
this
.
context
.
eventHub
.
off
(
"
myEvent
"
);
// 取消eventFunc1和eventFunc2对myEvent事件的订阅
}
eventFunc1
()
{
console
.
log
(
"
eventFunc1 is called
"
);
}
eventFunc2
()
{
console
.
log
(
"
eventFunc2 is called
"
);
}
}
```
## EventHub.emit
...
...
@@ -115,25 +121,26 @@ emit(event: string, ...args: Object[]): void;
| ...args | Object[] | 是 | 可变参数,事件触发时,传递给回调函数的参数。 |
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
export
default
class
MainAbility
extends
Ability
{
onForeground
()
{
this
.
context
.
eventHub
.
on
(
"
123
"
,
this
.
func1
);
// 结果:
// func1 is called,undefined,undefined
this
.
context
.
eventHub
.
emit
(
"
123
"
);
// 结果:
// func1 is called,1,undefined
this
.
context
.
eventHub
.
emit
(
"
123
"
,
1
);
// 结果:
// func1 is called,1,2
this
.
context
.
eventHub
.
emit
(
"
123
"
,
1
,
2
);
}
func1
(
a
,
b
)
{
console
.
log
(
"
func1 is called,
"
+
a
+
"
,
"
+
b
);
}
}
```
```
ts
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
export
default
class
MainAbility
extends
UIAbility
{
onForeground
()
{
this
.
context
.
eventHub
.
on
(
"
myEvent
"
,
this
.
eventFunc
);
// 结果:
// eventFunc is called,undefined,undefined
this
.
context
.
eventHub
.
emit
(
"
myEvent
"
);
// 结果:
// eventFunc is called,1,undefined
this
.
context
.
eventHub
.
emit
(
"
myEvent
"
,
1
);
// 结果:
// eventFunc is called,1,2
this
.
context
.
eventHub
.
emit
(
"
myEvent
"
,
1
,
2
);
}
eventFunc
(
argOne
,
argTwo
)
{
console
.
log
(
"
eventFunc is called,
"
+
argOne
+
"
,
"
+
argTwo
);
}
}
```
zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionContext.md
浏览文件 @
f6cb200c
...
...
@@ -5,7 +5,7 @@ ExtensionContext是Extension的上下文环境,继承自Context。
ExtensionContext模块提供访问特定Extension的资源的能力,对于拓展的Extension,可直接将ExtensionContext作为上下文环境,或者定义一个继承自ExtensionContext的类型作为上下文环境。如:ServiceExtension提供了ServiceExtensionContext,它在ExtensionContext的基础上扩展了启动、停止、绑定、解绑Ability的能力,详见
[
ServiceExtensionContext
](
js-apis-inner-application-serviceExtensionContext.md
)
。
> **说明:**
>
>
> - 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块接口仅可在Stage模型下使用。
...
...
@@ -110,4 +110,4 @@ export default class ServiceModel {
}
}
};
```
\ No newline at end of file
```
zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionRunningInfo.md
浏览文件 @
f6cb200c
# ExtensionRunningInfo
ExtensionRunningInfo模块
提供对Extension运行的相关信息和类型进行设置和查询的能力,可以通过
[
getExtensionRunningInfos
](
js-apis-app-ability-abilityManager.md#getextensionrunninginfos
)
获取。
ExtensionRunningInfo模块
封装了Extension运行的相关信息,可以通过
[
getExtensionRunningInfos接口
](
js-apis-app-ability-abilityManager.md#getextensionrunninginfos
)
获取。
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
本模块接口均为系统接口,三方应用不支持调用
>
-
本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
- 本模块被标记为@systemapi,对三方应用隐藏
## 使用说明
通过abilityManager中方法获取
。
导入abilityManager模块,通过调用abilityManager中的方法获取ExtensionRunningInfo
。
## 属性
...
...
@@ -17,29 +17,37 @@ ExtensionRunningInfo模块提供对Extension运行的相关信息和类型进行
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| extension |
ElementName | 是 | 否 | Extension匹配
信息。 |
| extension |
[
ElementName
](
js-apis-bundleManager-elementName.md
)
| 是 | 否 | Extension
信息。 |
| pid | number | 是 | 否 | 进程ID。 |
| uid | number | 是 | 否 |
用户ID
。 |
| uid | number | 是 | 否 |
应用程序的uid
。 |
| processName | string | 是 | 否 | 进程名称。 |
| startTime | number | 是 | 否 | Extension
启动时间
。 |
| startTime | number | 是 | 否 | Extension
被启动时的时间戳
。 |
| clientPackage | Array
<
String
>
| 是 | 否 | 表示当期进程下的所有包名。 |
| type |
[
bundle.ExtensionAbilityType
](
js-apis-Bundle.md
)
| 是 | 否 | Extension类型。 |
| type |
[
ExtensionAbilityType
](
js-apis-bundleManager.md#extensionabilitytype
)
| 是 | 否 | Extension类型。 |
**示例:**
```
ts
import
abilityManager
from
'
@ohos.application.abilityManager
'
;
let
upperLimit
=
1
;
abilityManager
.
getExtensionRunningInfos
(
upperLimit
,
(
err
,
data
)
=>
{
console
.
log
(
"
getExtensionRunningInfos err:
"
+
err
+
"
data:
"
+
JSON
.
stringify
(
data
));
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
let
extensionRunningInfo
=
data
[
i
];
console
.
log
(
"
extensionRunningInfo.extension:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
extension
));
console
.
log
(
"
extensionRunningInfo.pid:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
pid
));
console
.
log
(
"
extensionRunningInfo.uid:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
uid
));
console
.
log
(
"
extensionRunningInfo.processName:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
processName
));
console
.
log
(
"
extensionRunningInfo.startTime:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
startTime
));
console
.
log
(
"
extensionRunningInfo.clientPackage:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
clientPackage
));
console
.
log
(
"
extensionRunningInfo.type:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
type
));
}
});
```
\ No newline at end of file
import
abilityManager
from
'
@ohos.app.ability.abilityManager
'
var
upperLimit
=
1
;
function
getExtensionInfos
()
{
abilityManager
.
getExtensionRunningInfos
(
upperLimit
,
(
error
,
data
)
=>
{
if
(
error
&&
error
.
code
)
{
console
.
log
(
'
getForegroundApplications failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
return
;
}
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
let
extensionRunningInfo
=
data
[
i
];
console
.
log
(
"
extensionRunningInfo.extension:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
extension
));
console
.
log
(
"
extensionRunningInfo.pid:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
pid
));
console
.
log
(
"
extensionRunningInfo.uid:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
uid
));
console
.
log
(
"
extensionRunningInfo.processName:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
processName
));
console
.
log
(
"
extensionRunningInfo.startTime:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
startTime
));
console
.
log
(
"
extensionRunningInfo.clientPackage:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
clientPackage
));
console
.
log
(
"
extensionRunningInfo.type:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
type
));
}
});
}
```
zh-cn/application-dev/reference/apis/js-apis-inner-wantAgent-triggerInfo.md
浏览文件 @
f6cb200c
...
...
@@ -6,7 +6,7 @@
| 名称 | 类型 | 必填 | 说明 |
| ---------- | --- |-------------------- | ----------- |
| code | number | 是 |
result code
。 |
| code | number | 是 |
提供给目标wantAgent的自定义结果码
。 |
| want | Want | 否 | Want。 |
| permission | string | 否 | 权限定义。 |
| extraInfo | {[key: string]: any} | 否 | 额外数据。 |
zh-cn/application-dev/reference/apis/js-apis-mouseevent.md
浏览文件 @
f6cb200c
...
...
@@ -9,7 +9,7 @@
## 导入模块
```
js
import
{
Action
,
Button
,
Axis
,
AxisValue
,
MouseEvent
}
from
'
@ohos.multimodalInput.mouseEvent
'
;
import
{
Action
,
Button
,
Axis
,
AxisValue
,
MouseEvent
}
from
'
@ohos.multimodalInput.mouseEvent
'
;
```
## Action
...
...
zh-cn/application-dev/reference/apis/js-apis-pointer.md
浏览文件 @
f6cb200c
...
...
@@ -276,7 +276,7 @@ import window from '@ohos.window';
window
.
getTopWindow
((
error
,
win
)
=>
{
win
.
getProperties
((
error
,
properties
)
=>
{
var
windowId
=
properties
.
id
;
let
windowId
=
properties
.
id
;
if
(
windowId
<
0
)
{
console
.
log
(
`Invalid windowId`
);
return
;
...
...
@@ -319,7 +319,7 @@ import window from '@ohos.window';
window
.
getTopWindow
((
error
,
win
)
=>
{
win
.
getProperties
((
error
,
properties
)
=>
{
var
windowId
=
properties
.
id
;
let
windowId
=
properties
.
id
;
if
(
windowId
<
0
)
{
console
.
log
(
`Invalid windowId`
);
return
;
...
...
@@ -358,7 +358,7 @@ import window from '@ohos.window';
window
.
getTopWindow
((
error
,
win
)
=>
{
win
.
getProperties
((
error
,
properties
)
=>
{
var
windowId
=
properties
.
id
;
let
windowId
=
properties
.
id
;
if
(
windowId
<
0
)
{
console
.
log
(
`Invalid windowId`
);
return
;
...
...
@@ -396,7 +396,7 @@ import window from '@ohos.window';
window
.
getTopWindow
((
error
,
win
)
=>
{
win
.
getProperties
((
error
,
properties
)
=>
{
var
windowId
=
properties
.
id
;
let
windowId
=
properties
.
id
;
if
(
windowId
<
0
)
{
console
.
log
(
`Invalid windowId`
);
return
;
...
...
zh-cn/application-dev/reference/apis/js-apis-wantAgent.md
浏览文件 @
f6cb200c
# @ohos.wantAgent (WantAgent模块)
WantAgent模块提供了
触发、取消、比较WantAgent实例和获取bundle名称的能力,包括创建WantAgent实例、获取实例的用户ID、获取want信息等
。
WantAgent模块提供了
创建WantAgent实例、获取实例的用户ID、获取want信息、比较WantAgent实例和获取bundle名称等能力
。
> **说明:**
>
...
...
@@ -8,7 +8,7 @@ WantAgent模块提供了触发、取消、比较WantAgent实例和获取bundle
## 导入模块
```
j
s
```
t
s
import
WantAgent
from
'
@ohos.wantAgent
'
;
```
...
...
@@ -29,7 +29,7 @@ getWantAgent(info: WantAgentInfo, callback: AsyncCallback\<WantAgent\>): void
**示例:**
```
j
s
```
t
s
import
WantAgent
from
'
@ohos.wantAgent
'
;
//getWantAgent回调
...
...
@@ -91,7 +91,7 @@ getWantAgent(info: WantAgentInfo): Promise\<WantAgent\>
**示例:**
```
j
s
```
t
s
import
WantAgent
from
'
@ohos.wantAgent
'
;
...
...
@@ -147,7 +147,7 @@ getBundleName(agent: WantAgent, callback: AsyncCallback\<string\>): void
**示例:**
```
j
s
```
t
s
import
WantAgent
from
'
@ohos.wantAgent
'
;
...
...
@@ -224,7 +224,7 @@ getBundleName(agent: WantAgent): Promise\<string\>
**示例:**
```
j
s
```
t
s
import
WantAgent
from
'
@ohos.wantAgent
'
;
//wantAgent对象
...
...
@@ -287,7 +287,7 @@ getUid(agent: WantAgent, callback: AsyncCallback\<number\>): void
**示例:**
```
j
s
```
t
s
import
WantAgent
from
'
@ohos.wantAgent
'
;
...
...
@@ -364,7 +364,7 @@ getUid(agent: WantAgent): Promise\<number\>
**示例:**
```
j
s
```
t
s
import
WantAgent
from
'
@ohos.wantAgent
'
;
...
...
@@ -430,7 +430,7 @@ getWant(agent: WantAgent, callback: AsyncCallback\<Want\>): void
**示例:**
```
j
s
```
t
s
import
WantAgent
from
'
@ohos.wantAgent
'
;
...
...
@@ -509,7 +509,7 @@ getWant(agent: WantAgent): Promise\<Want\>
**示例:**
```
j
s
```
t
s
import
WantAgent
from
'
@ohos.wantAgent
'
;
...
...
@@ -573,7 +573,7 @@ cancel(agent: WantAgent, callback: AsyncCallback\<void\>): void
**示例:**
```
j
s
```
t
s
import
WantAgent
from
'
@ohos.wantAgent
'
;
...
...
@@ -650,7 +650,7 @@ cancel(agent: WantAgent): Promise\<void\>
**示例:**
```
j
s
```
t
s
import
WantAgent
from
'
@ohos.wantAgent
'
;
...
...
@@ -710,12 +710,12 @@ trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback\<Complet
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ----------------------------- | ---- | ------------------------------- |
| agent | WantAgent | 是 | WantAgent对象。 |
| triggerInfo |
TriggerInfo
| 是 | TriggerInfo对象。 |
| triggerInfo |
[
TriggerInfo
](
js-apis-inner-wantAgent-triggerInfo.md
)
| 是 | TriggerInfo对象。 |
| callback | AsyncCallback
\<
CompleteData
\>
| 否 | 主动激发WantAgent实例的回调方法。 |
**示例:**
```
j
s
```
t
s
import
WantAgent
from
'
@ohos.wantAgent
'
;
...
...
@@ -792,7 +792,7 @@ equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback\<boolean\
**示例:**
```
j
s
```
t
s
import
WantAgent
from
'
@ohos.wantAgent
'
;
...
...
@@ -872,7 +872,7 @@ equal(agent: WantAgent, otherAgent: WantAgent): Promise\<boolean\>
**示例:**
```
j
s
```
t
s
import
WantAgent
from
'
@ohos.wantAgent
'
;
...
...
@@ -936,7 +936,7 @@ getOperationType(agent: WantAgent, callback: AsyncCallback\<number>): void;
**示例:**
```
j
s
```
t
s
import
WantAgent
from
'
@ohos.wantAgent
'
;
//wantAgent对象
...
...
@@ -1002,7 +1002,7 @@ getOperationType(agent: WantAgent): Promise\<number>;
**示例:**
```
j
s
```
t
s
import
WantAgent
from
'
@ohos.wantAgent
'
;
//wantAgent对象
...
...
zh-cn/release-notes/changelogs/OpenHarmony_3.2.8.1/changelogs-inputmethod-framworks.md
0 → 100644
浏览文件 @
f6cb200c
# 输入法框架changeLog
## cl.inputmethod_frameworks.1 API错误信息返回方式变更
下列模块内部接口使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。在API9进行变更。
-
输入法框架模块:系统接口,@ohos.inputmethod.d.ts
-
输入法服务模块:系统接口,@ohos.inputmethodengine.d.ts
-
输入法ExtentionAbility模块:系统接口,@ohos.inputmethodextensionability.d.ts
-
输入法ExtentionContext模块:系统接口,@ohos.inputmethodextensioncontext.d.ts
-
输入法子类型模块:系统接口,@ohos.inputMethodSubtype.d.ts
异步接口:通过AsyncCallback或Promise的error对象返回错误信息。
同步接口:通过抛出异常的方式返回错误信息。
**变更影响**
基于此前版本开发的应用,需适配接口的错误信息返回方式,否则会影响原有业务逻辑。
**关键接口/组件变更**
在以下接口增加错误码处理:
-
getSetting(): InputMethodSetting;
-
getController(): InputMethodController;
-
switchInputMethod(target: InputMethodProperty, callback: AsyncCallback
<boolean>
): void;
-
switchInputMethod(target: InputMethodProperty): Promise
<boolean>
;
-
switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallback
<boolean>
): void;
-
switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise
<boolean>
;
-
switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype, callback: AsyncCallback
<boolean>
): void;
-
switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype): Promise
<boolean>
;
-
listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: AsyncCallback
<Array
<
InputMethodSubtype
>
>): void;
-
listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise
<Array
<
InputMethodSubtype
>
>;
-
listCurrentInputMethodSubtype(callback: AsyncCallback
<Array
<
InputMethodSubtype
>
>): void;
-
listCurrentInputMethodSubtype(): Promise
<Array
<
InputMethodSubtype
>
>;
-
getInputMethods(enable: boolean, callback: AsyncCallback
<Array
<
InputMethodProperty
>
>): void;
-
getInputMethods(enable: boolean): Promise
<Array
<
InputMethodProperty
>
>;
-
showOptionalInputMethods(callback: AsyncCallback
<boolean>
): void;
-
showOptionalInputMethods(): Promise
<boolean>
;
-
stopInputSession(callback: AsyncCallback
<boolean>
): void;
-
stopInputSession(): Promise
<boolean>
;
-
showSoftKeyboard(callback: AsyncCallback
<void>
): void;
-
showSoftKeyboard():Promise
<void>
;
-
hideSoftKeyboard(callback: AsyncCallback
<void>
): void;
-
hideSoftKeyboard():Promise
<void>
;
-
hide(callback: AsyncCallback
<void>
): void;
-
hide(): Promise
<void>
;
-
onCreate(want: Want): void;
-
onDestroy(): void;
InputClient 接口下:
-
sendKeyFunction(action: number, callback: AsyncCallback
<boolean>
): void;
-
sendKeyFunction(action: number): Promise
<boolean>
;
-
deleteForward(length: number, callback: AsyncCallback
<boolean>
): void;
-
deleteForward(length: number): Promise
<boolean>
;
-
deleteBackward(length: number, callback: AsyncCallback
<boolean>
): void;
-
deleteBackward(length: number): Promise
<boolean>
;
-
insertText(text: string, callback: AsyncCallback
<boolean>
): void;
-
insertText(text: string): Promise
<boolean>
;
-
getForward(length: number, callback: AsyncCallback
<string>
): void;
-
getForward(length: number): Promise
<string>
;
-
getBackward(length: number, callback: AsyncCallback
<string>
): void;
-
getBackward(length: number): Promise
<string>
;
-
getEditorAttribute(callback: AsyncCallback
<EditorAttribute>
): void;
-
getEditorAttribute(): Promise
<EditorAttribute>
;
-
moveCursor(direction: number, callback: AsyncCallback
<void>
): void;
-
moveCursor(direction: number): Promise
<void>
;
InputMethodExtensionAbility 类下:
-
onCreate(want: Want): void;
-
onDestroy(): void;
**适配指导**
异步接口以showOptionalInputMethods为例,示例代码如下:
callback回调:
```
js
import
inputMethod
from
'
@ohos.inputmethod
'
;
let
inputMethodSetting
=
inputMethod
.
getSetting
();
try
{
inputMethodSetting
.
showOptionalInputMethods
((
err
,
data
)
=>
{
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to showOptionalInputMethods:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in showing optionalInputMethods.
'
);
});
}
catch
(
err
)
{
console
.
error
(
'
Failed to showOptionalInputMethods:
'
+
JSON
.
stringify
(
err
));
}
```
Promise回调:
```
js
import
inputMethod
from
'
@ohos.inputmethod
'
;
let
inputMethodSetting
=
inputMethod
.
getSetting
();
inputMethodSetting
.
showOptionalInputMethods
().
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in showing optionalInputMethods.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to showOptionalInputMethods:
'
+
JSON
.
stringify
(
err
));
})
```
## cl.inputmethod_frameworks.2 API部分接口废弃
以下接口标记废除:
-
getInputMethodSetting(): InputMethodSetting;
-
getInputMethodController(): InputMethodController;
-
listInputMethod(callback: AsyncCallback
<Array
<
InputMethodProperty
>
>): void;
-
listInputMethod(): Promise
<Array
<
InputMethodProperty
>
>;
-
displayOptionalInputMethod(callback: AsyncCallback
<void>
): void;
-
displayOptionalInputMethod(): Promise
<void>
;
-
stopInput(callback: AsyncCallback
<boolean>
): void;
-
stopInput(): Promise
<boolean>
;
interface InputMethodProperty:
-
readonly packageName: string;
-
readonly methodId: string;
-
getInputMethodEngine(): InputMethodEngine;
-
createKeyboardDelegate(): KeyboardDelegate;
-
hideKeyboard(callback: AsyncCallback
<void>
): void;
-
hideKeyboard(): Promise
<void>
;
替代接口如下:
-
getSetting(): InputMethodSetting;
-
getController(): InputMethodController;
-
getInputMethods(enable: boolean, callback: AsyncCallback
<Array
<
InputMethodProperty
>
>): void;
-
getInputMethods(enable: boolean): Promise
<Array
<
InputMethodProperty
>
>;
-
showOptionalInputMethods(callback: AsyncCallback
<boolean>
): void;
-
showOptionalInputMethods(): Promise
<boolean>
;
-
stopInputSession(callback: AsyncCallback
<boolean>
): void;
-
stopInputSession(): Promise
<boolean>
;
interface InputMethodProperty:
-
readonly name: string;
-
readonly id: string;
-
getInputMethodAbility(): InputMethodAbility;
-
getKeyboardDelegate(): KeyboardDelegate;
-
hide(callback: AsyncCallback
<void>
): void;
-
hide(): Promise
<void>
;
**特别注意:**
使用getInputMethodAbility()接口获取到InputMethodAbility对象,代替使用getInputMethodEngine()接口获取InputMethodEngine对象。
使用InputMethodAbility中的方法,不要再使用InputMethodEngine中的方法。
使用InputMethodAbility中的on('inputStart')方法,获取到KeyboardController实例与InputClient实例,不要再使用InputMethodEngine中的on('inputStart')方法去获取TextInputClient实例。
之前:
```
js
inputMethodEngine
.
getInputMethodEngine
().
on
(
'
inputStart
'
,
(
kbController
,
textClient
)
=>
{
let
keyboardController
=
kbController
;
let
textInputClient
=
textClient
;
// 获取到TextInputClient实例
});
```
之后:
```
js
inputMethodEngine
.
getInputMethodAbility
().
on
(
'
inputStart
'
,
(
kbController
,
client
)
=>
{
let
keyboardController
=
kbController
;
let
inputClient
=
client
;
// // 获取到InputClient实例
});
```
## cl.inputmethod_frameworks.3 API部分接口变更
变更前:
-
listInputMethod(enable: boolean, callback: AsyncCallback
<Array
<
InputMethodProperty
>
>): void;
-
listInputMethod(enable: boolean): Promise
<Array
<
InputMethodProperty
>
>;
-
terminateSelf(callback: AsyncCallback
<void>
): void;
-
terminateSelf(): Promise
<void>
;
变更后:
-
getInputMethods(enable: boolean, callback: AsyncCallback
<Array
<
InputMethodProperty
>
>): void;
-
getInputMethods(enable: boolean): Promise
<Array
<
InputMethodProperty
>
>;
-
destroy(callback: AsyncCallback
<void>
): void;
-
destroy(): Promise
<void>
;
删除API9接口:
-
startAbility(want: Want, callback: AsyncCallback
<void>
): void;
-
startAbility(want: Want, options: StartOptions, callback: AsyncCallback
<void>
): void;
-
startAbility(want: Want, options?: StartOptions): Promise
<void>
;
其他新增接口:
-
on(type: 'imeChange', callback: (inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype) => void): void;
-
off(type: 'imeChange', callback?: (inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype) => void): void;
-
interface InputMethodProperty:
-
readonly label?: string;
-
readonly icon?: string;
-
readonly iconId?: number;
-
extra: object;
-
interface InputMethodAbility:
-
on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => void): void;
-
off(type: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => void): void;
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录