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

!23374 arkts 告警修复

Merge pull request !23374 from 耿文广/master
......@@ -50,18 +50,24 @@ setDisposedStatus(appId: string, disposedWant: Want): Promise\<void>
**示例:**
```ts
import { BusinessError } from '@ohos.base';
import Want from '@ohos.app.ability.Want';
import appControl from '@ohos.bundle.appControl';
let appId = "com.example.myapplication_xxxxx";
let want = {bundleName: 'com.example.myapplication'};
let want:Want = {bundleName: 'com.example.myapplication'};
try {
appControl.setDisposedStatus(appId, want)
.then(() => {
console.info('setDisposedStatus success');
}).catch((error) => {
console.error('setDisposedStatus failed ' + error.message);
}).catch((error: BusinessError) => {
let message = (error as BusinessError).message;
console.error('setDisposedStatus failed ' + message);
});
} catch (error) {
console.error('setDisposedStatus failed ' + error.message);
let message = (error as BusinessError).message;
console.error('setDisposedStatus failed ' + message);
}
```
......@@ -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) => {
appControl.setDisposedStatus(appId, want, (error: BusinessError, data) => {
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 = (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);
}).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);
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,6 +309,7 @@ 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";
......@@ -293,7 +318,8 @@ let want: Want;
try {
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);
}).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,9 +407,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) => {
if (error) {
console.error('deleteDisposedStatus failed ' + error.message);
return;
......@@ -386,7 +420,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 +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,6 +475,7 @@ appId是应用的唯一标识,由应用Bundle名称和签名信息决定,可
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
let bundleName = 'com.example.myapplication';
let appId: string;
......@@ -446,10 +484,12 @@ try {
.then((data) => {
appId = data.signatureInfo.appId;
console.info("appId is " + appId);
}).catch((error) => {
console.error("getBundleInfo failed " + error.message);
}).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
......@@ -34,15 +34,17 @@ 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 => {
bundleInstall.getBundleInstaller().then(installer => {
installer.install(hapFilePaths, installParam, err => {
if (err) {
console.error('install failed:' + JSON.stringify(err));
......@@ -50,8 +52,9 @@ bundle.getBundleInstaller().then(installer => {
console.info('install successfully.');
}
});
}).catch(error => {
console.error('getBundleInstaller failed. Cause: ' + error.message);
}).catch((error: BusinessError)=> {
let message = (error as BusinessError).message;
console.error('getBundleInstaller failed. Cause: ' + message);
});
```
......@@ -84,15 +87,17 @@ 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 => {
bundleInstall.getBundleInstaller().then(installer => {
installer.uninstall(bundleName, installParam, err => {
if (err) {
console.error('uninstall failed:' + JSON.stringify(err));
......@@ -100,8 +105,9 @@ bundle.getBundleInstaller().then(installer => {
console.info('uninstall successfully.');
}
});
}).catch(error => {
console.error('getBundleInstaller failed. Cause: ' + error.message);
}).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';
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 => {
bundleInstall.getBundleInstaller().then(installer => {
installer.uninstall(bundleName, installParam, err => {
if (err) {
console.error('recover failed:' + JSON.stringify(err));
console.error('uninstall failed:' + JSON.stringify(err));
} else {
console.info('recover successfully.');
console.info('uninstall successfully.');
}
});
}).catch(error => {
console.error('getBundleInstaller failed. Cause: ' + error.message);
}).catch((error: BusinessError) => {
let message = (error as BusinessError).message;
console.error('getBundleInstaller failed. Cause: ' + message);
});
```
......
......@@ -63,10 +63,12 @@ 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((error) => {
}).catch((error: BusinessError) => {
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) => {
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) => {
try {
let data = defaultAppMgr.isDefaultApplicationSync(defaultAppMgr.ApplicationType.BROWSER)
console.info('Operation successful. IsDefaultApplicationSync ? ' + JSON.stringify(data));
}).catch((error) => {
} 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((error) => {
})
.catch((error: BusinessError) => {
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((error) => {
})
.catch((error: BusinessError) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
});
});
```
## defaultAppMgr.getDefaultApplication
......@@ -222,8 +228,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) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
......@@ -231,7 +239,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) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
......@@ -272,14 +280,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) => {
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) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
......@@ -327,21 +337,19 @@ getDefaultApplicationSync(type: string, userId?: number): BundleInfo;
```ts
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
defaultAppMgr.getDefaultApplicationSync(defaultAppMgr.ApplicationType.BROWSER)
.then((data) => {
try {
let data = defaultAppMgr.getDefaultApplicationSync(defaultAppMgr.ApplicationType.BROWSER)
console.info('Operation successful. bundleInfo: ' + JSON.stringify(data));
})
.catch((error) => {
} catch(error) {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
});
};
defaultAppMgr.getDefaultApplicationSync("image/png")
.then((data) => {
try {
let data = defaultAppMgr.getDefaultApplicationSync("image/png")
console.info('Operation successful. bundleInfo: ' + JSON.stringify(data));
})
.catch((error) => {
} catch(error) {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
});
};
```
## defaultAppMgr.setDefaultApplication
......@@ -384,34 +392,29 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number):
```ts
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
import { BusinessError } from '@ohos.base';
let info = {
bundleName: "com.example.myapplication",
moduleName: "module01",
abilityName: "EntryAbility"
}).then((data) => {
}
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, info).then((data) => {
console.info('Operation successful.');
}).catch((error) => {
}).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) => {
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, info, userId).then((data) => {
console.info('Operation successful.');
}).catch((error) => {
}).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) => {
defaultAppMgr.setDefaultApplication("image/png", info, userId).then((data) => {
console.info('Operation successful.');
}).catch((error) => {
}).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, {
let info = {
bundleName: "com.example.myapplication",
moduleName: "module01",
abilityName: "EntryAbility"
}, userId, (err, data) => {
}
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", {
bundleName: "com.example.myapplication",
moduleName: "module01",
abilityName: "EntryAbility"
}, userId, (err, data) => {
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, {
import { BusinessError } from '@ohos.base';
let info = {
bundleName: "com.example.myapplication",
moduleName: "module01",
abilityName: "EntryAbility"
}, (err, data) => {
}
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", {
bundleName: "com.example.myapplication",
moduleName: "module01",
abilityName: "EntryAbility"
}, (err, data) => {
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, {
let info = {
bundleName: "com.example.myapplication",
moduleName: "module01",
abilityName: "EntryAbility"
}).then((data) => {
}
try {
defaultAppMgr.setDefaultApplicationSync(defaultAppMgr.ApplicationType.BROWSER, info);
console.info('Operation successful.');
}).catch((error) => {
} 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) => {
try {
defaultAppMgr.setDefaultApplicationSync(defaultAppMgr.ApplicationType.BROWSER, info, userId);
console.info('Operation successful.');
}).catch((error) => {
} 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) => {
try {
defaultAppMgr.setDefaultApplicationSync("image/png", info, userId);
console.info('Operation successful.');
}).catch((error) => {
} 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((error) => {
})
.catch((error: BusinessError) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
});
});
defaultAppMgr.resetDefaultApplication("image/png", userId)
.then((data) => {
.then((data) => {
console.info('Operation successful.');
})
.catch((error) => {
})
.catch((error: BusinessError) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
});
});
```
## defaultAppMgr.resetDefaultApplication
......@@ -684,8 +683,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) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
......@@ -693,7 +694,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) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
......@@ -733,7 +734,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) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
......@@ -741,7 +744,7 @@ defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (er
console.info('Operation successful.');
});
defaultAppMgr.resetDefaultApplication("image/png", (err, data) => {
defaultAppMgr.resetDefaultApplication("image/png", (err: BusinessError, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
......@@ -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) => {
try {
defaultAppMgr.resetDefaultApplicationSync(defaultAppMgr.ApplicationType.BROWSER, userId);
console.info('Operation successful.');
})
.catch((error) => {
} catch(error) {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
});
};
defaultAppMgr.resetDefaultApplicationSync("image/png", userId)
.then((data) => {
try {
defaultAppMgr.resetDefaultApplicationSync("image/png", userId);
console.info('Operation successful.');
})
.catch((error) => {
} 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.
先完成此消息的编辑!
想要评论请 注册