Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
cdfc8c46
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看板
未验证
提交
cdfc8c46
编写于
8月 29, 2023
作者:
耿
耿文广
提交者:
Gitee
8月 29, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md.
Signed-off-by:
N
耿文广
<
gengwenguang@huawei.com
>
上级
35f40311
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
190 addition
and
182 deletion
+190
-182
zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md
...plication-dev/reference/apis/js-apis-defaultAppManager.md
+190
-182
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md
浏览文件 @
cdfc8c46
...
...
@@ -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
:
defaultAppMgr
.
AsyncCallback
<
boolean
>
)
=>
{
.
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
));
});
```
...
...
@@ -92,13 +94,13 @@ isDefaultApplication(type: string, callback: AsyncCallback\<boolean>): void
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
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
;
}
console
.
info
(
'
Operation successful. IsDefaultApplication ?
'
+
JSON
.
stringify
(
data
));
});
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>
...
...
@@ -126,12 +128,12 @@ isDefaultApplicationSync(type: string): boolean;
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
isDefaultApplicationSync
(
defaultAppMgr
.
ApplicationType
.
BROWSER
)
.
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
boolean
>
)
=>
{
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
...
...
@@ -173,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
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
.
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
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
.
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
...
...
@@ -227,20 +231,20 @@ import defaultAppMgr from '@ohos.bundle.defaultAppManager';
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userId
=
100
;
defaultAppMgr
.
getDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
userId
,
(
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
(
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
:
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
"
,
userId
,
(
err
:
BusinessError
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -278,19 +282,19 @@ getDefaultApplication(type: string, callback: AsyncCallback\<BundleInfo>) : void
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
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
(
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
:
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
:
BusinessError
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -333,21 +337,19 @@ getDefaultApplicationSync(type: string, userId?: number): BundleInfo;
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
defaultAppMgr
.
getDefaultApplicationSync
(
defaultAppMgr
.
ApplicationType
.
BROWSER
)
.
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
console
.
info
(
'
Operation successful. bundleInfo:
'
+
JSON
.
stringify
(
data
));
})
.
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
defaultAppMgr
.
getDefaultApplicationSync
(
"
image/png
"
)
.
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
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
...
...
@@ -390,28 +392,30 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number):
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
let
info
:
defaultAppMgr
.
ElementName
=
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
info
=
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
}
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
));
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
,
info
,
userId
).
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
void
>
)
=>
{
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
"
,
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
"
,
info
,
userId
).
then
((
data
)
=>
{
console
.
info
(
'
Operation successful.
'
);
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
```
...
...
@@ -453,26 +457,26 @@ import defaultAppMgr from '@ohos.bundle.defaultAppManager';
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userId
=
100
;
let
info
:
defaultAppMgr
.
ElementName
=
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
let
info
=
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
}
defaultAppMgr
.
setDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
info
,
userId
,
(
err
err
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
});
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
err
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
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,26 +514,26 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
info
:
defaultAppMgr
.
ElementName
=
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
let
info
=
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
}
defaultAppMgr
.
setDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
info
,
(
err
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Operation successful.
'
);
});
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
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
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>
...
...
@@ -566,29 +570,32 @@ setDefaultApplicationSync(type: string, elementName: ElementName, userId?: numbe
```
ts
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
let
info
:
defaultAppMgr
.
ElementName
=
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
let
info
=
{
bundleName
:
"
com.example.myapplication
"
,
moduleName
:
"
module01
"
,
abilityName
:
"
EntryAbility
"
}
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
));
});
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
,
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
"
,
info
,
userId
).
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
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
...
...
@@ -623,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
:
defaultAppMgr
.
AsyncCallback
<
void
>
)
=>
{
.
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
:
defaultAppMgr
.
AsyncCallback
<
void
>
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful.
'
);
})
.
catch
((
e
rror
)
=>
{
})
.
catch
((
error
:
BusinessE
rror
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
});
```
## defaultAppMgr.resetDefaultApplication
...
...
@@ -677,20 +686,20 @@ import defaultAppMgr from '@ohos.bundle.defaultAppManager';
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userId
=
100
;
defaultAppMgr
.
resetDefaultApplication
(
defaultAppMgr
.
ApplicationType
.
BROWSER
,
userId
,
(
err
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
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
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
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.
'
);
});
```
...
...
@@ -727,20 +736,20 @@ resetDefaultApplication(type: string, callback: AsyncCallback\<void>) : void;
import
defaultAppMgr
from
'
@ohos.bundle.defaultAppManager
'
;
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
;
}
console
.
info
(
'
Operation successful.
'
);
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
:
BusinessError
,
data
:
defaultAppMgr
.
AsyncCallback
<
BundleInfo
>
)
=>
{
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.
'
);
});
```
...
...
@@ -776,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
:
defaultAppMgr
.
AsyncCallback
<
void
>
)
=>
{
console
.
info
(
'
Operation successful.
'
);
})
.
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
defaultAppMgr
.
resetDefaultApplicationSync
(
"
image/png
"
,
userId
)
.
then
((
data
:
defaultAppMgr
.
AsyncCallback
<
void
>
)
=>
{
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录