Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
d46730e1
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,发现更多精彩内容 >>
提交
d46730e1
编写于
8月 29, 2023
作者:
G
geng-wenguang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
arkts 告警修复
Signed-off-by:
N
geng-wenguang
<
gengwenguang@huawei.com
>
上级
7e6af2a2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
136 addition
and
94 deletion
+136
-94
zh-cn/application-dev/reference/apis/js-apis-appControl.md
zh-cn/application-dev/reference/apis/js-apis-appControl.md
+59
-22
zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md
...tion-dev/reference/apis/js-apis-bundle-BundleInstaller.md
+26
-15
zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md
...plication-dev/reference/apis/js-apis-defaultAppManager.md
+51
-57
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-appControl.md
浏览文件 @
d46730e1
...
...
@@ -50,6 +50,8 @@ setDisposedStatus(appId: string, disposedWant: Want): Promise\<void>
**示例:**
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
appId
=
"
com.example.myapplication_xxxxx
"
;
let
want
=
{
bundleName
:
'
com.example.myapplication
'
};
...
...
@@ -58,10 +60,12 @@ try {
.
then
(()
=>
{
console
.
info
(
'
setDisposedStatus success
'
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
setDisposedStatus failed
'
+
error
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
console
.
error
(
'
setDisposedStatus failed
'
+
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
setDisposedStatus failed
'
+
error
.
message
);
let
message
=
(
err
as
BusinessError
).
message
;
console
.
error
(
'
setDisposedStatus failed
'
+
message
);
}
```
...
...
@@ -96,19 +100,24 @@ setDisposedStatus(appId: string, disposedWant: Want, callback: AsyncCallback\<vo
**示例:**
```
ts
import
appControl
from
'
@ohos.bundle.appControl
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
appId
=
"
com.example.myapplication_xxxxx
"
;
let
want
=
{
bundleName
:
'
com.example.myapplication
'
};
try
{
appControl
.
setDisposedStatus
(
appId
,
want
,
(
error
,
data
)
=>
{
appControl
.
setDisposedStatus
(
appId
,
want
,
(
error
:
BusinessError
,
data
:
appControl
.
AsyncCallback
)
=>
{
if
(
error
)
{
console
.
error
(
'
setDisposedStatus failed
'
+
error
.
message
);
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
=
(
err
as
BusinessError
).
message
;
console
.
error
(
'
setDisposedStatus failed
'
+
message
);
}
```
...
...
@@ -143,6 +152,7 @@ setDisposedStatusSync(appId: string, disposedWant: Want): void;
```
ts
import
appControl
from
'
@ohos.bundle.appControl
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
Want
from
'
@ohos.app.ability.Want
'
;
let
appId
:
string
=
"
com.example.myapplication_xxxxx
"
;
...
...
@@ -151,7 +161,8 @@ let want: Want = {bundleName: 'com.example.myapplication'};
try
{
appControl
.
setDisposedStatusSync
(
appId
,
want
);
}
catch
(
error
)
{
console
.
error
(
'
setDisposedStatusSync failed
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
setDisposedStatusSync failed
'
+
message
);
}
```
...
...
@@ -190,17 +201,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
)
=>
{
.
then
((
data
:
appControl
.
AsyncCallback
)
=>
{
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
);
});
}
catch
(
error
)
{
console
.
error
(
'
getDisposedStatus failed
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getDisposedStatus failed
'
+
message
);
}
```
...
...
@@ -234,18 +250,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
)
=>
{
appControl
.
getDisposedStatus
(
appId
,
(
error
,
data
:
appControl
.
AsyncCallback
)
=>
{
if
(
error
)
{
console
.
error
(
'
getDisposedStatus failed
'
+
error
.
message
);
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
);
}
```
...
...
@@ -285,15 +306,17 @@ getDisposedStatusSync(appId: string): Want;
```
ts
import
appControl
from
'
@ohos.bundle.appControl
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
Want
from
'
@ohos.app.ability.Want
'
;
let
appId
:
string
=
"
com.example.myapplication_xxxxx
"
;
let
want
:
Want
;
try
{
want
=
appControl
.
getDisposedStatusSync
(
appId
);
want
=
appControl
.
getDisposedStatusSync
(
appId
);
}
catch
(
error
)
{
console
.
error
(
'
getDisposedStatusSync failed
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getDisposedStatusSync failed
'
+
message
);
}
```
...
...
@@ -332,6 +355,8 @@ deleteDisposedStatus(appId: string): Promise\<void>
**示例:**
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
appId
=
"
com.example.myapplication_xxxxx
"
;
try
{
...
...
@@ -339,10 +364,12 @@ try {
.
then
(()
=>
{
console
.
info
(
'
deleteDisposedStatus success
'
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
deleteDisposedStatus failed
'
+
error
.
message
);
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
);
}
```
...
...
@@ -376,9 +403,12 @@ deleteDisposedStatus(appId: string, callback: AsyncCallback\<void>) : void
**示例:**
```
ts
import
appControl
from
'
@ohos.bundle.appControl
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
appId
=
"
com.example.myapplication_xxxxx
"
;
try
{
appControl
.
deleteDisposedStatus
(
appId
,
(
error
,
data
)
=>
{
appControl
.
deleteDisposedStatus
(
appId
,
(
error
:
BusinessError
,
data
:
appControl
.
AsyncCallback
)
=>
{
if
(
error
)
{
console
.
error
(
'
deleteDisposedStatus failed
'
+
error
.
message
);
return
;
...
...
@@ -386,7 +416,8 @@ try {
console
.
info
(
'
deleteDisposedStatus success
'
);
});
}
catch
(
error
)
{
console
.
error
(
'
deleteDisposedStatus failed
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
deleteDisposedStatus failed
'
+
message
);
}
```
...
...
@@ -420,13 +451,15 @@ deleteDisposedStatusSync(appId: string) : void
```
ts
import
appControl
from
'
@ohos.bundle.appControl
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
appId
:
string
=
"
com.example.myapplication_xxxxx
"
;
try
{
appControl
.
deleteDisposedStatusSync
(
appId
);
}
catch
(
error
)
{
console
.
error
(
'
deleteDisposedStatusSync failed
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
deleteDisposedStatusSync failed
'
+
message
);
}
```
...
...
@@ -438,18 +471,22 @@ appId是应用的唯一标识,由应用Bundle名称和签名信息决定,可
```
ts
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
import
appControl
from
'
@ohos.bundle.appControl
'
;
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
)
=>
{
.
then
((
data
:
appControl
.
AsyncCallback
)
=>
{
appId
=
data
.
signatureInfo
.
appId
;
console
.
info
(
"
appId is
"
+
appId
);
}).
catch
((
error
)
=>
{
console
.
error
(
"
getBundleInfo failed
"
+
error
.
message
);
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
浏览文件 @
d46730e1
...
...
@@ -35,15 +35,18 @@ SystemCapability.BundleManager.BundleFramework
```
ts
import
bundle
from
'
@ohos.bundle
'
;
let
hapFilePaths
=
[
'
/data/storage/el2/base/haps/entry/files/
'
];
let
installParam
=
{
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
=>
{
bundle
.
getBundleInstaller
().
then
(
installer
:
bundleInstall
.
BundleInstaller
=>
{
installer
.
install
(
hapFilePaths
,
installParam
,
err
:
BusinessError
=>
{
if
(
err
)
{
console
.
error
(
'
install failed:
'
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -51,7 +54,8 @@ bundle.getBundleInstaller().then(installer => {
}
});
}).
catch
(
error
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
});
```
...
...
@@ -85,15 +89,18 @@ SystemCapability.BundleManager.BundleFramework
```
ts
import
bundle
from
'
@ohos.bundle
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
installParam
=
{
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
=>
{
bundle
.
getBundleInstaller
().
then
(
installer
:
bundleInstall
.
BundleInstaller
=>
{
installer
.
uninstall
(
bundleName
,
installParam
,
err
:
BusinessError
=>
{
if
(
err
)
{
console
.
error
(
'
uninstall failed:
'
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -101,7 +108,8 @@ bundle.getBundleInstaller().then(installer => {
}
});
}).
catch
(
error
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
});
```
## BundleInstaller.recover<sup>(deprecated)<sup>
...
...
@@ -134,16 +142,18 @@ SystemCapability.BundleManager.BundleFramework
```
ts
import
bundle
from
'
@ohos.bundle
'
;
import
bundleInstall
from
'
@ohos.bundle.installer
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
=
'
com.example.myapplication
'
;
let
installParam
=
{
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
=>
{
bundle
.
getBundleInstaller
().
then
(
installer
:
bundleInstall
.
BundleInstaller
=>
{
installer
.
recover
(
bundleName
,
installParam
,
err
:
BusinessError
=>
{
if
(
err
)
{
console
.
error
(
'
recover failed:
'
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -151,7 +161,8 @@ bundle.getBundleInstaller().then(installer => {
}
});
}).
catch
(
error
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
message
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md
浏览文件 @
d46730e1
...
...
@@ -64,7 +64,7 @@ isDefaultApplication(type: string): Promise\<boolean>
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
isDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
)
.
then
((
data
)
=>
{
.
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
boolean
>
)
=>
{
console
.
info
(
'
Operation successful. IsDefaultApplication ?
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -90,7 +90,9 @@ isDefaultApplication(type: string, callback: AsyncCallback\<boolean>): void
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
isDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
(
err
,
data
)
=>
{
import
{
BusinessError
}
from
'
@ohos.base
'
;
defaultAppMgr
.
isDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
(
err
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
boolean
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -125,7 +127,7 @@ isDefaultApplicationSync(type: string): boolean;
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
isDefaultApplicationSync
(
defaultAppMgr
.
ApplicationType
.
BROWSER
)
.
then
((
data
)
=>
{
.
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
boolean
>
)
=>
{
console
.
info
(
'
Operation successful. IsDefaultApplicationSync ?
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -172,7 +174,7 @@ getDefaultApplication(type: string, userId?: number): Promise\<BundleInfo>
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
getDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
)
.
then
((
data
)
=>
{
.
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
})
.
catch
((
error
)
=>
{
...
...
@@ -180,7 +182,7 @@ defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER)
});
defaultAppMgr
.
getDefaultApplication
(
"
image/png
"
)
.
then
((
data
)
=>
{
.
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
})
.
catch
((
error
)
=>
{
...
...
@@ -222,8 +224,10 @@ 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
)
=>
{
defaultAppMgr
.
getDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
userId
,
(
err
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -231,7 +235,7 @@ defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, userI
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
});
defaultAppMgr
.
getDefaultApplication
(
"
image/png
"
,
userId
,
(
err
,
data
)
=>
{
defaultAppMgr
.
getDefaultApplication
(
"
image/png
"
,
userId
,
(
err
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -272,14 +276,16 @@ getDefaultApplication(type: string, callback: AsyncCallback\<BundleInfo>) : void
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
getDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
(
err
,
data
)
=>
{
import
{
BusinessError
}
from
'
@ohos.base
'
;
defaultAppMgr
.
getDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
(
err
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
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
)
=>
{
defaultAppMgr
.
getDefaultApplication
(
"
image/png
"
,
(
err
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -328,7 +334,7 @@ getDefaultApplicationSync(type: string, userId?: number): BundleInfo;
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
getDefaultApplicationSync
(
defaultAppMgr
.
ApplicationType
.
BROWSER
)
.
then
((
data
)
=>
{
.
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
})
.
catch
((
error
)
=>
{
...
...
@@ -336,7 +342,7 @@ defaultAppMgr.getDefaultApplicationSync(defaultAppMgr.ApplicationType.BROWSER)
});
defaultAppMgr
.
getDefaultApplicationSync
(
"
image/png
"
)
.
then
((
data
)
=>
{
.
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
})
.
catch
((
error
)
=>
{
...
...
@@ -384,32 +390,25 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number):
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
setDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
{
let
info
:
defaultAppMgr
.
ElementName
=
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
}).
then
((
data
)
=>
{
}
defaultAppMgr
.
setDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
info
).
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
void
>
)
=>
{
console
.
info
(
'
Operation successful.
'
);
}).
catch
((
error
)
=>
{
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
)
=>
{
defaultAppMgr
.
setDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
info
,
userId
).
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
void
>
)
=>
{
console
.
info
(
'
Operation successful.
'
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
defaultAppMgr
.
setDefaultApplication
(
"
image/png
"
,
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
},
userId
).
then
((
data
)
=>
{
defaultAppMgr
.
setDefaultApplication
(
"
image/png
"
,
info
,
userId
).
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
void
>
)
=>
{
console
.
info
(
'
Operation successful.
'
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -451,12 +450,15 @@ 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
,
{
let
info
:
defaultAppMgr
.
ElementName
=
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
},
userId
,
(
err
,
data
)
=>
{
}
defaultAppMgr
.
setDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
info
,
userId
,
(
errerr
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -464,11 +466,7 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
console
.
info
(
'
Operation successful.
'
);
});
defaultAppMgr
.
setDefaultApplication
(
"
image/png
"
,
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
},
userId
,
(
err
,
data
)
=>
{
defaultAppMgr
.
setDefaultApplication
(
"
image/png
"
,
info
,
userId
,
(
errerr
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -510,11 +508,14 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
setDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
{
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
info
:
defaultAppMgr
.
ElementName
=
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
},
(
err
,
data
)
=>
{
}
defaultAppMgr
.
setDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
info
,
(
err
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -522,11 +523,7 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
console
.
info
(
'
Operation successful.
'
);
});
defaultAppMgr
.
setDefaultApplication
(
"
image/png
"
,
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
},
(
err
,
data
)
=>
{
defaultAppMgr
.
setDefaultApplication
(
"
image/png
"
,
info
,
(
err
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -569,32 +566,25 @@ setDefaultApplicationSync(type: string, elementName: ElementName, userId?: numbe
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
setDefaultApplicationSync
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
{
let
info
:
defaultAppMgr
.
ElementName
=
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
}).
then
((
data
)
=>
{
}
defaultAppMgr
.
setDefaultApplicationSync
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
info
).
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
console
.
info
(
'
Operation successful.
'
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
let
userId
=
100
;
defaultAppMgr
.
setDefaultApplicationSync
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
},
userId
).
then
((
data
)
=>
{
defaultAppMgr
.
setDefaultApplicationSync
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
info
,
userId
).
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
console
.
info
(
'
Operation successful.
'
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
defaultAppMgr
.
setDefaultApplicationSync
(
"
image/png
"
,
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
},
userId
).
then
((
data
)
=>
{
defaultAppMgr
.
setDefaultApplicationSync
(
"
image/png
"
,
info
,
userId
).
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
console
.
info
(
'
Operation successful.
'
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -635,7 +625,7 @@ resetDefaultApplication(type: string, userId?: number): Promise\<void>
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
let
userId
=
100
;
defaultAppMgr
.
resetDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
userId
)
.
then
((
data
)
=>
{
.
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
void
>
)
=>
{
console
.
info
(
'
Operation successful.
'
);
})
.
catch
((
error
)
=>
{
...
...
@@ -643,7 +633,7 @@ defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, use
});
defaultAppMgr
.
resetDefaultApplication
(
"
image/png
"
,
userId
)
.
then
((
data
)
=>
{
.
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
void
>
)
=>
{
console
.
info
(
'
Operation successful.
'
);
})
.
catch
((
error
)
=>
{
...
...
@@ -684,8 +674,10 @@ 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
)
=>
{
defaultAppMgr
.
resetDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
userId
,
(
err
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -693,7 +685,7 @@ defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, use
console
.
info
(
'
Operation successful.
'
);
});
defaultAppMgr
.
resetDefaultApplication
(
"
image/png
"
,
userId
,
(
err
,
data
)
=>
{
defaultAppMgr
.
resetDefaultApplication
(
"
image/png
"
,
userId
,
(
err
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -733,7 +725,9 @@ resetDefaultApplication(type: string, callback: AsyncCallback\<void>) : void;
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
resetDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
(
err
,
data
)
=>
{
import
{
BusinessError
}
from
'
@ohos.base
'
;
defaultAppMgr
.
resetDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
(
err
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -741,7 +735,7 @@ defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (er
console
.
info
(
'
Operation successful.
'
);
});
defaultAppMgr
.
resetDefaultApplication
(
"
image/png
"
,
(
err
,
data
)
=>
{
defaultAppMgr
.
resetDefaultApplication
(
"
image/png
"
,
(
err
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -784,7 +778,7 @@ resetDefaultApplicationSync(type: string, userId?: number): void;
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
let
userId
=
100
;
defaultAppMgr
.
resetDefaultApplicationSync
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
userId
)
.
then
((
data
)
=>
{
.
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
void
>
)
=>
{
console
.
info
(
'
Operation successful.
'
);
})
.
catch
((
error
)
=>
{
...
...
@@ -792,7 +786,7 @@ defaultAppMgr.resetDefaultApplicationSync(defaultAppMgr.ApplicationType.BROWSER,
});
defaultAppMgr
.
resetDefaultApplicationSync
(
"
image/png
"
,
userId
)
.
then
((
data
)
=>
{
.
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
void
>
)
=>
{
console
.
info
(
'
Operation successful.
'
);
})
.
catch
((
error
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录