未验证 提交 64241241 编写于 作者: O openharmony_ci 提交者: Gitee

!23575 资料修改

Merge pull request !23575 from 耿文广/master
...@@ -394,25 +394,32 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number): ...@@ -394,25 +394,32 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number):
import defaultAppMgr from '@ohos.bundle.defaultAppManager'; import defaultAppMgr from '@ohos.bundle.defaultAppManager';
import { BusinessError } from '@ohos.base'; import { BusinessError } from '@ohos.base';
let info = { defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
moduleName: "module01", moduleName: "module01",
abilityName: "EntryAbility" abilityName: "EntryAbility"
} }).then((data) => {
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, info).then((data) => {
console.info('Operation successful.'); console.info('Operation successful.');
}).catch((error: BusinessError) => { }).catch((error: BusinessError) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error)); console.error('Operation failed. Cause: ' + JSON.stringify(error));
}); });
let userId = 100; let userId = 100;
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, info, userId).then((data) => { defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.example.myapplication",
moduleName: "module01",
abilityName: "EntryAbility"
}, userId).then((data) => {
console.info('Operation successful.'); console.info('Operation successful.');
}).catch((error: BusinessError) => { }).catch((error: BusinessError) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error)); console.error('Operation failed. Cause: ' + JSON.stringify(error));
}); });
defaultAppMgr.setDefaultApplication("image/png", info, userId).then((data) => { defaultAppMgr.setDefaultApplication("image/png", {
bundleName: "com.example.myapplication",
moduleName: "module01",
abilityName: "EntryAbility"
}, userId).then((data) => {
console.info('Operation successful.'); console.info('Operation successful.');
}).catch((error: BusinessError) => { }).catch((error: BusinessError) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error)); console.error('Operation failed. Cause: ' + JSON.stringify(error));
...@@ -457,12 +464,11 @@ import defaultAppMgr from '@ohos.bundle.defaultAppManager'; ...@@ -457,12 +464,11 @@ import defaultAppMgr from '@ohos.bundle.defaultAppManager';
import { BusinessError } from '@ohos.base'; import { BusinessError } from '@ohos.base';
let userId = 100; let userId = 100;
let info = { defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
moduleName: "module01", moduleName: "module01",
abilityName: "EntryAbility" abilityName: "EntryAbility"
} }, userId, (err: BusinessError, data) => {
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, info, userId, (err: BusinessError, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
return; return;
...@@ -470,7 +476,11 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, info, ...@@ -470,7 +476,11 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, info,
console.info('Operation successful.'); console.info('Operation successful.');
}); });
defaultAppMgr.setDefaultApplication("image/png", info, userId, (err: BusinessError, data) => { defaultAppMgr.setDefaultApplication("image/png", {
bundleName: "com.example.myapplication",
moduleName: "module01",
abilityName: "EntryAbility"
}, userId, (err: BusinessError, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
return; return;
...@@ -514,12 +524,11 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal ...@@ -514,12 +524,11 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal
import defaultAppMgr from '@ohos.bundle.defaultAppManager'; import defaultAppMgr from '@ohos.bundle.defaultAppManager';
import { BusinessError } from '@ohos.base'; import { BusinessError } from '@ohos.base';
let info = { defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
moduleName: "module01", moduleName: "module01",
abilityName: "EntryAbility" abilityName: "EntryAbility"
} }, (err: BusinessError, data) => {
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, info, (err: BusinessError, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
return; return;
...@@ -527,7 +536,11 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, info, ...@@ -527,7 +536,11 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, info,
console.info('Operation successful.'); console.info('Operation successful.');
}); });
defaultAppMgr.setDefaultApplication("image/png", info, (err: BusinessError, data) => { defaultAppMgr.setDefaultApplication("image/png", {
bundleName: "com.example.myapplication",
moduleName: "module01",
abilityName: "EntryAbility"
}, (err: BusinessError, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
return; return;
...@@ -570,13 +583,12 @@ setDefaultApplicationSync(type: string, elementName: ElementName, userId?: numbe ...@@ -570,13 +583,12 @@ setDefaultApplicationSync(type: string, elementName: ElementName, userId?: numbe
```ts ```ts
import defaultAppMgr from '@ohos.bundle.defaultAppManager'; import defaultAppMgr from '@ohos.bundle.defaultAppManager';
let info = { try {
defaultAppMgr.setDefaultApplicationSync(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
moduleName: "module01", moduleName: "module01",
abilityName: "EntryAbility" abilityName: "EntryAbility"
} });
try {
defaultAppMgr.setDefaultApplicationSync(defaultAppMgr.ApplicationType.BROWSER, info);
console.info('Operation successful.'); console.info('Operation successful.');
} catch(error) { } catch(error) {
console.error('Operation failed. Cause: ' + JSON.stringify(error)); console.error('Operation failed. Cause: ' + JSON.stringify(error));
...@@ -584,14 +596,22 @@ try { ...@@ -584,14 +596,22 @@ try {
let userId = 100; let userId = 100;
try { try {
defaultAppMgr.setDefaultApplicationSync(defaultAppMgr.ApplicationType.BROWSER, info, userId); defaultAppMgr.setDefaultApplicationSync(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.example.myapplication",
moduleName: "module01",
abilityName: "EntryAbility"
}, userId);
console.info('Operation successful.'); console.info('Operation successful.');
} catch(error) { } catch(error) {
console.error('Operation failed. Cause: ' + JSON.stringify(error)); console.error('Operation failed. Cause: ' + JSON.stringify(error));
}; };
try { try {
defaultAppMgr.setDefaultApplicationSync("image/png", info, userId); defaultAppMgr.setDefaultApplicationSync("image/png", {
bundleName: "com.example.myapplication",
moduleName: "module01",
abilityName: "EntryAbility"
}, userId);
console.info('Operation successful.'); console.info('Operation successful.');
} catch(error) { } catch(error) {
console.error('Operation failed. Cause: ' + JSON.stringify(error)); console.error('Operation failed. Cause: ' + JSON.stringify(error));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册