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

!23533 arkts 告警清理monthly

Merge pull request !23533 from 耿文广/monthly_20230815
......@@ -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);
}
```
......@@ -81,7 +87,7 @@ setDisposedStatus(appId: string, disposedWant: Want, callback: AsyncCallback\<vo
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------------------------- | ---- | --------------------------------------- |
| appId | string | 是 | 需要设置处置的应用的appId<br> appId是应用的唯一标识,由应用Bundle名称和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 |
| appId | string | 是 | 需要设置处置的应用的appId<br> appId是应用的唯一标识,由应用Bundle名称和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 |
| disposedWant | Want | 是 | 对应用的处置意图。 |
| callback | AsyncCallback\<void> | 是 | 回调函数,当设置处置状态成功,err为null,否则为错误对象。 |
......@@ -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);
}
```
......@@ -128,7 +140,7 @@ getDisposedStatus(appId: string): Promise\<Want>;
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | --------------------------------------- |
| appId | string | 是 | 要查询的应用的appId<br> appId是应用的唯一标识,由应用Bundle名称和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 |
| appId | string | 是 | 要查询的应用的appId<br> appId是应用的唯一标识,由应用Bundle名称和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 |
**返回值:**
......@@ -147,17 +159,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);
}
```
......@@ -177,7 +194,7 @@ getDisposedStatus(appId: string, callback: AsyncCallback\<Want>): void;
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | --------------------------------------- |
| appId | string | 是 | 要查询的应用的appId<br> appId是应用的唯一标识,由应用Bundle名称和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 |
| appId | string | 是 | 要查询的应用的appId<br> appId是应用的唯一标识,由应用Bundle名称和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 |
| callback | AsyncCallback\<Want> | 是 | 回调函数。当获取应用的处置状态成功时,err为null,data为获取到的处置状态;否则为错误对象。 |
**错误码:**
......@@ -191,18 +208,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);
}
```
......@@ -222,7 +244,7 @@ deleteDisposedStatus(appId: string): Promise\<void>
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | --------------------------------------- |
| appId | string | 是 | 要删除处置状态的应用的appId<br> appId是应用的唯一标识,由应用Bundle名称和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 |
| appId | string | 是 | 要删除处置状态的应用的appId<br> appId是应用的唯一标识,由应用Bundle名称和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 |
**返回值:**
......@@ -241,17 +263,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);
}
```
......@@ -284,21 +311,6 @@ deleteDisposedStatus(appId: string, callback: AsyncCallback\<void>) : void
**示例:**
```ts
let appId = "com.example.myapplication_xxxxx";
try {
appControl.deleteDisposedStatus(appId, (error, data) => {
if (error) {
console.error('deleteDisposedStatus failed ' + error.message);
return;
}
console.info('deleteDisposedStatus success');
});
} catch (error) {
console.error('deleteDisposedStatus failed ' + error.message);
}
```
## 获取应用的appId
appId是应用的唯一标识,由应用Bundle名称和签名信息决定,可以通过[getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo)接口获取。
......@@ -307,18 +319,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
......@@ -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);
});
```
......
......@@ -68,13 +68,16 @@ on(type: BundleChangedEvent, callback: Callback\<BundleChangedInfo>): void;
```ts
import bundleMonitor from '@ohos.bundle.bundleMonitor';
import { BusinessError } from '@ohos.base';
try {
bundleMonitor.on('add', (bundleChangeInfo) => {
console.info(`bundleName : ${bundleChangeInfo.bundleName} userId : ${bundleChangeInfo.userId}`);
})
} catch (errData) {
console.log(`errData is errCode:${errData.errCode} message:${errData.message}`);
let message = (errData as BusinessError).message;
let errCode = (errData as BusinessError).code;
console.log(`errData is errCode:${errCode} message:${message}`);
}
```
......@@ -101,10 +104,13 @@ off(type: BundleChangedEvent, callback?: Callback\<BundleChangedInfo>): void;
```ts
import bundleMonitor from '@ohos.bundle.bundleMonitor';
import { BusinessError } from '@ohos.base';
try {
bundleMonitor.off('add');
} catch (errData) {
console.log(`errData is errCode:${errData.errCode} message:${errData.message}`);
let message = (errData as BusinessError).message;
let errCode = (errData as BusinessError).code;
console.log(`errData is errCode:${errCode} message:${message}`);
}
```
\ No newline at end of file
......@@ -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((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(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) => {
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.getDefaultApplication
......@@ -138,21 +142,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
......@@ -189,21 +195,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));
});
```
......@@ -239,19 +247,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));
});
```
......@@ -295,35 +305,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));
});
```
......@@ -362,30 +367,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
......@@ -421,29 +425,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.resetDefaultApplication
......@@ -478,22 +481,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
......@@ -529,21 +534,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.');
});
```
......@@ -578,19 +585,21 @@ 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.');
});
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册