Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
1bcc6ee5
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,发现更多精彩内容 >>
未验证
提交
1bcc6ee5
编写于
8月 29, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 29, 2023
浏览文件
操作
浏览文件
下载
差异文件
!23374 arkts 告警修复
Merge pull request !23374 from 耿文广/master
上级
80565257
44381605
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
366 addition
and
316 deletion
+366
-316
zh-cn/application-dev/reference/apis/js-apis-appControl.md
zh-cn/application-dev/reference/apis/js-apis-appControl.md
+99
-59
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-defaultAppManager.md
...plication-dev/reference/apis/js-apis-defaultAppManager.md
+210
-208
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-appControl.md
浏览文件 @
1bcc6ee5
...
...
@@ -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
);
});
appControl
.
setDisposedStatus
(
appId
,
want
)
.
then
(()
=>
{
console
.
info
(
'
setDisposedStatus success
'
);
}).
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
);
}
```
...
...
@@ -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
);
}
```
...
...
@@ -143,6 +155,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 +164,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 +204,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
);
}
```
...
...
@@ -234,18 +253,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
);
}
```
...
...
@@ -285,15 +309,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,17 +358,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
);
}
```
...
...
@@ -376,17 +407,21 @@ 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
,
(
e
rror
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
'
deleteDisposedStatus failed
'
+
error
.
message
);
return
;
}
console
.
info
(
'
deleteDisposedStatus success
'
);
});
appControl
.
deleteDisposedStatus
(
appId
,
(
error
:
BusinessE
rror
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
'
deleteDisposedStatus failed
'
+
error
.
message
);
return
;
}
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 +455,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 +475,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
浏览文件 @
1bcc6ee5
...
...
@@ -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-defaultAppManager.md
浏览文件 @
1bcc6ee5
...
...
@@ -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.isDefaultApplicationSync<sup>10+</sup>
...
...
@@ -124,12 +128,12 @@ isDefaultApplicationSync(type: string): boolean;
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
isDefaultApplicationSync
(
defaultAppMgr
.
ApplicationType
.
BROWSER
)
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. IsDefaultApplicationSync ?
'
+
JSON
.
stringify
(
data
));
}
).
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
}
)
;
try
{
let
data
=
defaultAppMgr
.
isDefaultApplicationSync
(
defaultAppMgr
.
ApplicationType
.
BROWSER
)
console
.
info
(
'
Operation successful. IsDefaultApplicationSync ?
'
+
JSON
.
stringify
(
data
));
}
catch
(
error
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
};
```
## defaultAppMgr.getDefaultApplication
...
...
@@ -171,21 +175,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
...
...
@@ -222,21 +228,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
));
});
```
...
...
@@ -272,19 +280,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
));
});
```
...
...
@@ -327,21 +337,19 @@ getDefaultApplicationSync(type: string, userId?: number): BundleInfo;
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
getDefaultApplicationSync
(
defaultAppMgr
.
ApplicationType
.
BROWSER
)
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
})
.
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
defaultAppMgr
.
getDefaultApplicationSync
(
"
image/png
"
)
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
})
.
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
try
{
let
data
=
defaultAppMgr
.
getDefaultApplicationSync
(
defaultAppMgr
.
ApplicationType
.
BROWSER
)
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
}
catch
(
error
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
};
try
{
let
data
=
defaultAppMgr
.
getDefaultApplicationSync
(
"
image/png
"
)
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
}
catch
(
error
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
};
```
## defaultAppMgr.setDefaultApplication
...
...
@@ -384,35 +392,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
));
});
```
...
...
@@ -451,30 +454,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
...
...
@@ -510,29 +512,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.setDefaultApplicationSync<sup>10+</sup>
...
...
@@ -569,36 +570,32 @@ setDefaultApplicationSync(type: string, elementName: ElementName, userId?: numbe
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
setDefaultApplicationSync
(
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
));
});
let
info
=
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
}
try
{
defaultAppMgr
.
setDefaultApplicationSync
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
info
);
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
)
=>
{
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
)
=>
{
console
.
info
(
'
Operation successful.
'
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
try
{
defaultAppMgr
.
setDefaultApplicationSync
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
info
,
userId
);
console
.
info
(
'
Operation successful.
'
);
}
catch
(
error
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
};
try
{
defaultAppMgr
.
setDefaultApplicationSync
(
"
image/png
"
,
info
,
userId
);
console
.
info
(
'
Operation successful.
'
);
}
catch
(
error
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
};
```
## defaultAppMgr.resetDefaultApplication
...
...
@@ -633,22 +630,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
...
...
@@ -684,21 +683,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.
'
);
});
```
...
...
@@ -733,20 +734,22 @@ 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.
'
);
});
```
...
...
@@ -782,20 +785,19 @@ resetDefaultApplicationSync(type: string, userId?: number): void;
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
let
userId
=
100
;
defaultAppMgr
.
resetDefaultApplicationSync
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
userId
)
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful.
'
);
})
.
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
defaultAppMgr
.
resetDefaultApplicationSync
(
"
image/png
"
,
userId
)
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful.
'
);
})
.
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
let
userId
=
100
;
try
{
defaultAppMgr
.
resetDefaultApplicationSync
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
userId
);
console
.
info
(
'
Operation successful.
'
);
}
catch
(
error
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
};
try
{
defaultAppMgr
.
resetDefaultApplicationSync
(
"
image/png
"
,
userId
);
console
.
info
(
'
Operation successful.
'
);
}
catch
(
error
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
};
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录