Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
76a0b1a4
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看板
未验证
提交
76a0b1a4
编写于
8月 30, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 30, 2023
浏览文件
操作
浏览文件
下载
差异文件
!23533 arkts 告警清理monthly
Merge pull request !23533 from 耿文广/monthly_20230815
上级
e56ee52e
82e6e7b2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
295 addition
and
257 deletion
+295
-257
zh-cn/application-dev/reference/apis/js-apis-appControl.md
zh-cn/application-dev/reference/apis/js-apis-appControl.md
+77
-62
zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md
...tion-dev/reference/apis/js-apis-bundle-BundleInstaller.md
+57
-49
zh-cn/application-dev/reference/apis/js-apis-bundleMonitor.md
...n/application-dev/reference/apis/js-apis-bundleMonitor.md
+8
-2
zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md
...plication-dev/reference/apis/js-apis-defaultAppManager.md
+153
-144
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-appControl.md
浏览文件 @
76a0b1a4
...
...
@@ -50,18 +50,24 @@ setDisposedStatus(appId: string, disposedWant: Want): Promise\<void>
**示例:**
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
Want
from
'
@ohos.app.ability.Want
'
;
import
appControl
from
'
@ohos.bundle.appControl
'
;
let
appId
=
"
com.example.myapplication_xxxxx
"
;
let
want
=
{
bundleName
:
'
com.example.myapplication
'
};
let
want
:
Want
=
{
bundleName
:
'
com.example.myapplication
'
};
try
{
appControl
.
setDisposedStatus
(
appId
,
want
)
.
then
(()
=>
{
console
.
info
(
'
setDisposedStatus success
'
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
setDisposedStatus failed
'
+
error
.
message
);
}).
catch
((
error
:
BusinessError
)
=>
{
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
setDisposedStatus failed
'
+
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
setDisposedStatus failed
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
setDisposedStatus failed
'
+
message
);
}
```
...
...
@@ -81,7 +87,7 @@ setDisposedStatus(appId: string, disposedWant: Want, callback: AsyncCallback\<vo
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------------------------- | ---- | --------------------------------------- |
| appId | string | 是 | 需要设置处置的应用的appId
<br>
appId是应用的唯一标识,由应用Bundle名称和签名信息决定,获取方法参见
[
获取应用的appId
](
#获取应用的appid
)
。 |
| appId | string | 是 | 需要设置处置的应用的appId
。
<br>
appId是应用的唯一标识,由应用Bundle名称和签名信息决定,获取方法参见
[
获取应用的appId
](
#获取应用的appid
)
。 |
| disposedWant | Want | 是 | 对应用的处置意图。 |
| callback | AsyncCallback
\<
void> | 是 | 回调函数,当设置处置状态成功,err为null,否则为错误对象。 |
...
...
@@ -96,19 +102,25 @@ setDisposedStatus(appId: string, disposedWant: Want, callback: AsyncCallback\<vo
**示例:**
```
ts
import
appControl
from
'
@ohos.bundle.appControl
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
Want
from
'
@ohos.app.ability.Want
'
;
let
appId
=
"
com.example.myapplication_xxxxx
"
;
let
want
=
{
bundleName
:
'
com.example.myapplication
'
};
let
want
:
Want
=
{
bundleName
:
'
com.example.myapplication
'
};
try
{
appControl
.
setDisposedStatus
(
appId
,
want
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
'
setDisposedStatus failed
'
+
error
.
message
);
return
;
}
console
.
info
(
'
setDisposedStatus success
'
);
});
appControl
.
setDisposedStatus
(
appId
,
want
,
(
error
:
BusinessError
,
data
)
=>
{
if
(
error
)
{
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
setDisposedStatus failed
'
+
message
);
return
;
}
console
.
info
(
'
setDisposedStatus success
'
);
});
}
catch
(
error
)
{
console
.
error
(
'
setDisposedStatus failed
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
setDisposedStatus failed
'
+
message
);
}
```
...
...
@@ -128,7 +140,7 @@ getDisposedStatus(appId: string): Promise\<Want>;
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | --------------------------------------- |
| appId | string | 是 | 要查询的应用的appId
<br>
appId是应用的唯一标识,由应用Bundle名称和签名信息决定,获取方法参见
[
获取应用的appId
](
#获取应用的appid
)
。 |
| appId | string | 是 | 要查询的应用的appId
。
<br>
appId是应用的唯一标识,由应用Bundle名称和签名信息决定,获取方法参见
[
获取应用的appId
](
#获取应用的appid
)
。 |
**返回值:**
...
...
@@ -147,17 +159,22 @@ getDisposedStatus(appId: string): Promise\<Want>;
**示例:**
```
ts
import
appControl
from
'
@ohos.bundle.appControl
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
appId
=
"
com.example.myapplication_xxxxx
"
;
try
{
appControl
.
getDisposedStatus
(
appId
)
.
then
((
data
)
=>
{
console
.
info
(
'
getDisposedStatus success. DisposedStatus:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
error
(
'
getDisposedStatus failed
'
+
error
.
message
);
});
appControl
.
getDisposedStatus
(
appId
)
.
then
((
data
)
=>
{
console
.
info
(
'
getDisposedStatus success. DisposedStatus:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
:
BusinessError
)
=>
{
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getDisposedStatus failed
'
+
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getDisposedStatus failed
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getDisposedStatus failed
'
+
message
);
}
```
...
...
@@ -177,7 +194,7 @@ getDisposedStatus(appId: string, callback: AsyncCallback\<Want>): void;
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | --------------------------------------- |
| appId | string | 是 | 要查询的应用的appId
<br>
appId是应用的唯一标识,由应用Bundle名称和签名信息决定,获取方法参见
[
获取应用的appId
](
#获取应用的appid
)
。 |
| appId | string | 是 | 要查询的应用的appId
。
<br>
appId是应用的唯一标识,由应用Bundle名称和签名信息决定,获取方法参见
[
获取应用的appId
](
#获取应用的appid
)
。 |
| callback | AsyncCallback
\<
Want> | 是 | 回调函数。当获取应用的处置状态成功时,err为null,data为获取到的处置状态;否则为错误对象。 |
**错误码:**
...
...
@@ -191,18 +208,23 @@ getDisposedStatus(appId: string, callback: AsyncCallback\<Want>): void;
**示例:**
```
ts
import
appControl
from
'
@ohos.bundle.appControl
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
appId
=
"
com.example.myapplication_xxxxx
"
;
try
{
appControl
.
getDisposedStatus
(
appId
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
'
getDisposedStatus failed
'
+
error
.
message
);
return
;
}
console
.
info
(
'
getDisposedStatus success. DisposedStatus:
'
+
JSON
.
stringify
(
data
));
});
appControl
.
getDisposedStatus
(
appId
,
(
error
,
data
)
=>
{
if
(
error
)
{
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getDisposedStatus failed
'
+
message
);
return
;
}
console
.
info
(
'
getDisposedStatus success. DisposedStatus:
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
error
)
{
console
.
error
(
'
getDisposedStatus failed
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getDisposedStatus failed
'
+
message
);
}
```
...
...
@@ -222,7 +244,7 @@ deleteDisposedStatus(appId: string): Promise\<void>
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | --------------------------------------- |
| appId | string | 是 | 要删除处置状态的应用的appId
<br>
appId是应用的唯一标识,由应用Bundle名称和签名信息决定,获取方法参见
[
获取应用的appId
](
#获取应用的appid
)
。 |
| appId | string | 是 | 要删除处置状态的应用的appId
。
<br>
appId是应用的唯一标识,由应用Bundle名称和签名信息决定,获取方法参见
[
获取应用的appId
](
#获取应用的appid
)
。 |
**返回值:**
...
...
@@ -241,17 +263,22 @@ deleteDisposedStatus(appId: string): Promise\<void>
**示例:**
```
ts
import
appControl
from
'
@ohos.bundle.appControl
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
appId
=
"
com.example.myapplication_xxxxx
"
;
try
{
appControl
.
deleteDisposedStatus
(
appId
)
.
then
(()
=>
{
console
.
info
(
'
deleteDisposedStatus success
'
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
deleteDisposedStatus failed
'
+
error
.
message
);
});
appControl
.
deleteDisposedStatus
(
appId
)
.
then
(()
=>
{
console
.
info
(
'
deleteDisposedStatus success
'
);
}).
catch
((
error
:
BusinessError
)
=>
{
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
deleteDisposedStatus failed
'
+
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
deleteDisposedStatus failed
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
deleteDisposedStatus failed
'
+
message
);
}
```
...
...
@@ -284,21 +311,6 @@ deleteDisposedStatus(appId: string, callback: AsyncCallback\<void>) : void
**示例:**
```
ts
let
appId
=
"
com.example.myapplication_xxxxx
"
;
try
{
appControl
.
deleteDisposedStatus
(
appId
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
'
deleteDisposedStatus failed
'
+
error
.
message
);
return
;
}
console
.
info
(
'
deleteDisposedStatus success
'
);
});
}
catch
(
error
)
{
console
.
error
(
'
deleteDisposedStatus failed
'
+
error
.
message
);
}
```
## 获取应用的appId
appId是应用的唯一标识,由应用Bundle名称和签名信息决定,可以通过
[
getBundleInfo
](
js-apis-bundleManager.md#bundlemanagergetbundleinfo
)
接口获取。
...
...
@@ -307,18 +319,21 @@ appId是应用的唯一标识,由应用Bundle名称和签名信息决定,可
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
appId
:
string
;
try
{
bundleManager
.
getBundleInfo
(
bundleName
,
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_WITH_SIGNATURE_INFO
)
.
then
((
data
)
=>
{
appId
=
data
.
signatureInfo
.
appId
;
console
.
info
(
"
appId is
"
+
appId
);
}).
catch
((
error
)
=>
{
console
.
error
(
"
getBundleInfo failed
"
+
error
.
message
);
});
bundleManager
.
getBundleInfo
(
bundleName
,
bundleManager
.
BundleFlag
.
GET_BUNDLE_INFO_WITH_SIGNATURE_INFO
)
.
then
((
data
)
=>
{
appId
=
data
.
signatureInfo
.
appId
;
console
.
info
(
"
appId is
"
+
appId
);
}).
catch
((
error
:
BusinessError
)
=>
{
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
"
getBundleInfo failed
"
+
message
);
});
}
catch
(
error
)
{
console
.
error
(
"
getBundleInfo failed
"
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
"
getBundleInfo failed
"
+
message
);
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md
浏览文件 @
76a0b1a4
...
...
@@ -34,24 +34,27 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
```
ts
import
bundle
from
'
@ohos.bundle
'
;
let
hapFilePaths
=
[
'
/data/storage/el2/base/haps/entry/files/
'
];
let
installParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
,
import
bundleInstall
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
hapFilePaths
:
Array
<
string
>
=
[
'
/data/storage/el2/base/haps/entry/files/
'
];
let
installParam
:
bundleInstall
.
InstallParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
,
};
bundle
.
getBundleInstaller
().
then
(
installer
=>
{
installer
.
install
(
hapFilePaths
,
installParam
,
err
=>
{
if
(
err
)
{
console
.
error
(
'
install failed:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
'
install successfully.
'
);
}
});
}).
catch
(
error
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
bundleInstall
.
getBundleInstaller
().
then
(
installer
=>
{
installer
.
install
(
hapFilePaths
,
installParam
,
err
=>
{
if
(
err
)
{
console
.
error
(
'
install failed:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
'
install successfully.
'
);
}
});
}).
catch
((
error
:
BusinessError
)
=>
{
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
});
```
...
...
@@ -84,24 +87,27 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
```
ts
import
bundle
from
'
@ohos.bundle
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
installParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
,
import
bundleInstall
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
:
string
=
'
com.example.myapplication
'
;
let
installParam
:
bundleInstall
.
InstallParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
,
};
bundle
.
getBundleInstaller
().
then
(
installer
=>
{
installer
.
uninstall
(
bundleName
,
installParam
,
err
=>
{
if
(
err
)
{
console
.
error
(
'
uninstall failed:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
'
uninstall successfully.
'
);
}
});
}).
catch
(
error
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
bundleInstall
.
getBundleInstaller
().
then
(
installer
=>
{
installer
.
uninstall
(
bundleName
,
installParam
,
err
=>
{
if
(
err
)
{
console
.
error
(
'
uninstall failed:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
'
uninstall successfully.
'
);
}
});
}).
catch
((
error
:
BusinessError
)
=>
{
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
});
```
## BundleInstaller.recover<sup>(deprecated)<sup>
...
...
@@ -133,25 +139,27 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
```
ts
import
bundle
from
'
@ohos.bundle
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
installParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
,
import
bundleInstall
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
:
string
=
'
com.example.myapplication
'
;
let
installParam
:
bundleInstall
.
InstallParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
,
};
bundle
.
getBundleInstaller
().
then
(
installer
=>
{
installer
.
recover
(
bundleName
,
installParam
,
err
=>
{
if
(
err
)
{
console
.
error
(
'
recover failed:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
'
recover successfully.
'
);
}
});
}).
catch
(
error
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
bundleInstall
.
getBundleInstaller
().
then
(
installer
=>
{
installer
.
uninstall
(
bundleName
,
installParam
,
err
=>
{
if
(
err
)
{
console
.
error
(
'
uninstall failed:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
'
uninstall successfully.
'
);
}
});
}).
catch
((
error
:
BusinessError
)
=>
{
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-bundleMonitor.md
浏览文件 @
76a0b1a4
...
...
@@ -68,13 +68,16 @@ on(type: BundleChangedEvent, callback: Callback\<BundleChangedInfo>): void;
```
ts
import
bundleMonitor
from
'
@ohos.bundle.bundleMonitor
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
bundleMonitor
.
on
(
'
add
'
,
(
bundleChangeInfo
)
=>
{
console
.
info
(
`bundleName :
${
bundleChangeInfo
.
bundleName
}
userId :
${
bundleChangeInfo
.
userId
}
`
);
})
}
catch
(
errData
)
{
console
.
log
(
`errData is errCode:
${
errData
.
errCode
}
message:
${
errData
.
message
}
`
);
let
message
=
(
errData
as
BusinessError
).
message
;
let
errCode
=
(
errData
as
BusinessError
).
code
;
console
.
log
(
`errData is errCode:
${
errCode
}
message:
${
message
}
`
);
}
```
...
...
@@ -101,10 +104,13 @@ off(type: BundleChangedEvent, callback?: Callback\<BundleChangedInfo>): void;
```
ts
import
bundleMonitor
from
'
@ohos.bundle.bundleMonitor
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
bundleMonitor
.
off
(
'
add
'
);
}
catch
(
errData
)
{
console
.
log
(
`errData is errCode:
${
errData
.
errCode
}
message:
${
errData
.
message
}
`
);
let
message
=
(
errData
as
BusinessError
).
message
;
let
errCode
=
(
errData
as
BusinessError
).
code
;
console
.
log
(
`errData is errCode:
${
errCode
}
message:
${
message
}
`
);
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md
浏览文件 @
76a0b1a4
...
...
@@ -63,11 +63,13 @@ isDefaultApplication(type: string): Promise\<boolean>
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
defaultAppMgr
.
isDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. IsDefaultApplication ?
'
+
JSON
.
stringify
(
data
));
}).
catch
((
e
rror
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
}).
catch
((
error
:
BusinessE
rror
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
```
...
...
@@ -90,13 +92,15 @@ isDefaultApplication(type: string, callback: AsyncCallback\<boolean>): void
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
isDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful. IsDefaultApplication ?
'
+
JSON
.
stringify
(
data
));
});
import
{
BusinessError
}
from
'
@ohos.base
'
;
defaultAppMgr
.
isDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
(
err
:
BusinessError
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful. IsDefaultApplication ?
'
+
JSON
.
stringify
(
data
));
});
```
## defaultAppMgr.getDefaultApplication
...
...
@@ -138,21 +142,23 @@ getDefaultApplication(type: string, userId?: number): Promise\<BundleInfo>
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
defaultAppMgr
.
getDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
})
.
catch
((
e
rror
)
=>
{
})
.
catch
((
error
:
BusinessE
rror
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
});
defaultAppMgr
.
getDefaultApplication
(
"
image/png
"
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
})
.
catch
((
e
rror
)
=>
{
})
.
catch
((
error
:
BusinessE
rror
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
});
```
## defaultAppMgr.getDefaultApplication
...
...
@@ -189,21 +195,23 @@ getDefaultApplication(type: string, userId: number, callback: AsyncCallback\<Bun
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userId
=
100
;
defaultAppMgr
.
getDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
userId
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
defaultAppMgr
.
getDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
userId
,
(
err
:
BusinessError
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
});
defaultAppMgr
.
getDefaultApplication
(
"
image/png
"
,
userId
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
defaultAppMgr
.
getDefaultApplication
(
"
image/png
"
,
userId
,
(
err
:
BusinessError
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -239,19 +247,21 @@ getDefaultApplication(type: string, callback: AsyncCallback\<BundleInfo>) : void
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
getDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
import
{
BusinessError
}
from
'
@ohos.base
'
;
defaultAppMgr
.
getDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
(
err
:
BusinessError
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
});
defaultAppMgr
.
getDefaultApplication
(
"
image/png
"
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
defaultAppMgr
.
getDefaultApplication
(
"
image/png
"
,
(
err
:
BusinessError
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -295,35 +305,30 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number):
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
setDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
}).
then
((
data
)
=>
{
console
.
info
(
'
Operation successful.
'
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
info
=
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
}
defaultAppMgr
.
setDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
info
).
then
((
data
)
=>
{
console
.
info
(
'
Operation successful.
'
);
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
let
userId
=
100
;
defaultAppMgr
.
setDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
},
userId
).
then
((
data
)
=>
{
console
.
info
(
'
Operation successful.
'
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
defaultAppMgr
.
setDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
info
,
userId
).
then
((
data
)
=>
{
console
.
info
(
'
Operation successful.
'
);
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
defaultAppMgr
.
setDefaultApplication
(
"
image/png
"
,
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
},
userId
).
then
((
data
)
=>
{
console
.
info
(
'
Operation successful.
'
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
defaultAppMgr
.
setDefaultApplication
(
"
image/png
"
,
info
,
userId
).
then
((
data
)
=>
{
console
.
info
(
'
Operation successful.
'
);
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
```
...
...
@@ -362,30 +367,29 @@ setDefaultApplication(type: string, elementName: ElementName, userId: number, ca
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userId
=
100
;
defaultAppMgr
.
setDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
},
userId
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
});
defaultAppMgr
.
setDefaultApplication
(
"
image/png
"
,
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
},
userId
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
});
let
info
=
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
}
defaultAppMgr
.
setDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
info
,
userId
,
(
err
:
BusinessError
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
});
defaultAppMgr
.
setDefaultApplication
(
"
image/png
"
,
info
,
userId
,
(
err
:
BusinessError
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
});
```
## defaultAppMgr.setDefaultApplication
...
...
@@ -421,29 +425,28 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
setDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
},
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
});
defaultAppMgr
.
setDefaultApplication
(
"
image/png
"
,
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
},
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
});
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
info
=
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
}
defaultAppMgr
.
setDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
info
,
(
err
:
BusinessError
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
});
defaultAppMgr
.
setDefaultApplication
(
"
image/png
"
,
info
,
(
err
:
BusinessError
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
});
```
## defaultAppMgr.resetDefaultApplication
...
...
@@ -478,22 +481,24 @@ resetDefaultApplication(type: string, userId?: number): Promise\<void>
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userId
=
100
;
defaultAppMgr
.
resetDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
userId
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful.
'
);
})
.
catch
((
e
rror
)
=>
{
})
.
catch
((
error
:
BusinessE
rror
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
});
defaultAppMgr
.
resetDefaultApplication
(
"
image/png
"
,
userId
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful.
'
);
})
.
catch
((
e
rror
)
=>
{
})
.
catch
((
error
:
BusinessE
rror
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
});
```
## defaultAppMgr.resetDefaultApplication
...
...
@@ -529,21 +534,23 @@ resetDefaultApplication(type: string, userId: number, callback: AsyncCallback\<v
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userId
=
100
;
defaultAppMgr
.
resetDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
userId
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
defaultAppMgr
.
resetDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
userId
,
(
err
:
BusinessError
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
});
defaultAppMgr
.
resetDefaultApplication
(
"
image/png
"
,
userId
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
defaultAppMgr
.
resetDefaultApplication
(
"
image/png
"
,
userId
,
(
err
:
BusinessError
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
});
```
...
...
@@ -578,19 +585,21 @@ resetDefaultApplication(type: string, callback: AsyncCallback\<void>) : void;
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
resetDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
import
{
BusinessError
}
from
'
@ohos.base
'
;
defaultAppMgr
.
resetDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
(
err
:
BusinessError
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
});
defaultAppMgr
.
resetDefaultApplication
(
"
image/png
"
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
defaultAppMgr
.
resetDefaultApplication
(
"
image/png
"
,
(
err
:
BusinessError
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
});
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录