提交 53ffa66e 编写于 作者: J jidong 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/docs into dev_101701

Signed-off-by: Njidong <jidong4@huawei.com>
......@@ -164,6 +164,24 @@ zh-cn/application-dev/reference/arkui-js/ @HelloCrease
zh-cn/application-dev/reference/arkui-ts/ @HelloCrease
zh-cn/application-dev/reference/native-apis @RayShih
zh-cn/application-dev/reference/native-lib @RayShih
zh-cn/application-dev/quick-start/start-overview.md @ge-yafang
zh-cn/application-dev/quick-start/start-with-ets.md @ge-yafang
zh-cn/application-dev/quick-start/start-with-ets-low-code.md @ge-yafang
zh-cn/application-dev/quick-start/start-with-js.md @ge-yafang
zh-cn/application-dev/quick-start/start-with-js-low-code.md @ge-yafang
zh-cn/application-dev/quick-start/deveco-studio-user-guide-for-openharmony.md @ge-yafang
zh-cn/application-dev/quick-start/package-structure.md @RayShih
zh-cn/application-dev/quick-start/basic-resource-file-categories.md @RayShih
zh-cn/application-dev/quick-start/syscap.md @RayShih
zh-cn/application-dev/napi/napi-guidelines.md @RayShih
zh-cn/application-dev/napi/drawing-guidelines.md @ge-yafang
zh-cn/application-dev/napi/rawfile-guidelines.md @HelloCrease
zh-cn/application-dev/reference/js-service-widget-ui/ @HelloCrease
zh-cn/application-dev/website.md @zengyawen
zh-cn/application-dev/faqs/ @zengyawen
zh-cn/application-dev/file-management/ @qinxiaowang
zh-cn/application-dev/application-test/ @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-DataUriUtils.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-ability-errorCode.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-ability-wantConstant.md @RayShih
......@@ -186,7 +204,6 @@ zh-cn/application-dev/reference/apis/js-apis-particleAbility.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-service-extension-ability.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-uripermissionmanager.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-application-Want.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-wantAgent.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md @RayShih
......@@ -209,7 +226,7 @@ zh-cn/application-dev/reference/apis/js-apis-application-shellCmdResult.md @RayS
zh-cn/application-dev/reference/apis/js-apis-commonEvent.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-emitter.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-notification.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-reminderAgent.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-reminderAgent.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-eventhub.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-Bundle.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md @RayShih
......@@ -277,15 +294,15 @@ zh-cn/application-dev/reference/apis/js-apis-http.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-request.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-socket.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-webSocket.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-nfcTag.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-nfcTech.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-tagSession.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-connectedTag.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-nfcTag.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-nfcTech.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-tagSession.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-connectedTag.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-rpc.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-wifi.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-wifiext.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-accessibility.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-wifi.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-wifiext.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-accessibility.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-faultLogger.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-hiappevent.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-hichecker.md @zengyawen
......@@ -293,31 +310,31 @@ zh-cn/application-dev/reference/apis/js-apis-hidebug.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-hilog.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-hitracechain.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-hitracemeter.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-system-time.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-system-time.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-timer.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-battery-info.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-brightness.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-device-info.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-battery-info.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-brightness.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-device-info.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-device-manager.md
zh-cn/application-dev/reference/apis/js-apis-geolocation.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-geolocation.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-power.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-runninglock.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-power.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-runninglock.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-sensor.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-system-sensor.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-system-parameter.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-thermal.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-system-parameter.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-thermal.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-update.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-usb.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-colorSpaceManager.mdd @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-colorSpaceManager.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-vibrator.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-appAccount.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-distributed-account.md @zengyawen
......@@ -349,24 +366,84 @@ zh-cn/application-dev/reference/apis/js-apis-hisysevent.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-privacyManager.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-uiappearance.md @HelloCrease
zh-cn/application-dev/quick-start/start-overview.md @ge-yafang
zh-cn/application-dev/quick-start/start-with-ets.md @ge-yafang
zh-cn/application-dev/quick-start/start-with-ets-low-code.md @ge-yafang
zh-cn/application-dev/quick-start/start-with-js.md @ge-yafang
zh-cn/application-dev/quick-start/start-with-js-low-code.md @ge-yafang
zh-cn/application-dev/quick-start/deveco-studio-user-guide-for-openharmony.md @ge-yafang
zh-cn/application-dev/quick-start/package-structure.md @RayShih
zh-cn/application-dev/quick-start/basic-resource-file-categories.md @RayShih
zh-cn/application-dev/quick-start/syscap.md @RayShih
zh-cn/application-dev/napi/napi-guidelines.md @RayShih
zh-cn/application-dev/napi/drawing-guidelines.md @ge-yafang
zh-cn/application-dev/napi/rawfile-guidelines.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-buffer.md @zengyawen
zh-cn/application-dev/reference/js-service-widget-ui @HelloCrease
zh-cn/application-dev/website.md @zengyawen
zh-cn/application-dev/faqs/ @zengyawen
zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-userfilemanager.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-buffer.md @zengyawen
zh-cn/application-dev/reference/apis/Readme-CN.md @zengyawen
zh-cn/application-dev/file-management/ @qinxiaowang
\ No newline at end of file
zh-cn/application-dev/reference/apis/development-intro.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-accessibility-extension-context.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-application-abilityManager.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-application-applicationContext.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-application-EnvironmentCallback.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInfo.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-bundle-CustomizeData.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-bundle-defaultAppManager.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-bundle-ElementName.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-bundle-ExtensionAbilityInfo.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-bundle-HapModuleInfo.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-Bundle-InnerBundleManager.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-bundle-Metadata.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-bundle-ModuleInfo.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-bundle-PermissionDef.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-bundle-remoteAbilityInfo.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-bytrace.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-continuation-continuationExtraParams.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-continuation-continuationManager.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-continuation-continuationResult.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-dispatchInfo.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-distributedMissionManager.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-errorManager.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-inputevent.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-ability.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-context.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-keycode.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-keyevent.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-logs.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-mouseevent.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-nfcController.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-nfctech.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-pointer.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-processrunninginformation.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-securityLabel.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-system-app.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-system-battery.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-system-brightness.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-system-configuration.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-system-device.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-system-fetch.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-system-file.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-system-location.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-system-mediaquery.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-system-network.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-system-notification.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-system-package.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-system-prompt.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-system-request.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-system-router.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-system-timer.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-system-vibrate.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-touchevent.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-accessibility-config.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-application-quickFixManager.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-Bundle-BundleStatusCallback.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-bundle-PackInfo.md @RayShih
zh-cn/application-dev/reference/apis/js-apis-enterpriseDeviceManager-DeviceSettingsManager.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-fileAccess.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-fileExtensionInfo.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-net-policy.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-net-sharing.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-net-statistics.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-tlsSocket.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-reminderAgentManager.md @HelloCrease
......@@ -56,7 +56,7 @@ The methods are used to set the display orientation of the current ability.
**Example**
```javascript
import featureAbility from '@ohos.ability.featureAbility'
import bundle from '../@ohos.bundle';
import bundle from '@ohos.bundle';
export default {
onCreate() {
......@@ -79,7 +79,7 @@ The following describes the contexts provided by the stage model in detail.
### application/Context
**application/Context** is the base class context that provides basic application information such as **resourceManager**, **applicationInfo**, **cacheDir**, and **area**. It also provides basic application methods such as **createBundleContext**.
**application/Context** is the base class context. It provides basic application information, such as **resourceManager**, **applicationInfo**, **cacheDir**, and **area**. It also provides basic application methods such as **createModuleContext**.
**d.ts statement**
......
......@@ -12,8 +12,8 @@ An ability can be launched in the **standard**, **singleton**, or **specified**
| Launch Type | Description |Action |
| ----------- | ------- |---------------- |
| standard | Multi-instance | A new instance is started each time an ability starts.|
| singleton | Singleton | The ability has only one instance in the system. If an instance already exists when an ability is started, that instance is reused.|
| standard | Standard mode. | A new instance is started each time an ability starts.|
| singleton | Singleton mode. | The ability has only one instance in the system. If an instance already exists when an ability is started, that instance is reused.|
| specified | Instance-specific| The internal service of an ability determines whether to create multiple instances during running.|
By default, the singleton mode is used. The following is an example of the `module.json5` file:
......
......@@ -52,9 +52,9 @@ Examples are given below.
3. Implement the data provider services. For example, implement data storage of the data provider by using a database, reading and writing files, or accessing the network.
```ts
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS "
const DB_NAME = "DB00.db";
const TBL_NAME = "TBL00";
const DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS "
+ TBL_NAME
+ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, isStudent BOOLEAN, Binary BINARY)";
......@@ -132,9 +132,9 @@ Examples are given below.
1. Import the dependencies.
```ts
import Ability from '@ohos.application.Ability'
import dataShare from '@ohos.data.dataShare'
import dataSharePredicates from '@ohos.data.dataSharePredicates'
import Ability from '@ohos.application.Ability';
import dataShare from '@ohos.data.dataShare';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
```
2. Define the URI string for communicating with the data provider.
......@@ -164,29 +164,25 @@ Examples are given below.
```ts
// Construct a piece of data.
var valuesBucket = { "name": "ZhangSan", "age": 21, "isStudent": false, "Binary": new Uint8Array([1, 2, 3]) };
var updateBucket = { "name": "LiSi", "age": 18, "isStudent": true, "Binary": new Uint8Array([1, 2, 3]) };
let da = new dataSharePredicates.DataSharePredicates();
var valArray = new Array("*");
let people = new Array(
{ "name": "LiSi", "age": 41, "Binary": ar },
{ "name": "WangWu", "age": 21, "Binary": arr },
{ "name": "ZhaoLiu", "age": 61, "Binary": arr });
let valuesBucket = { "name": "ZhangSan", "age": 21, "isStudent": false, "Binary": new Uint8Array([1, 2, 3]) };
let updateBucket = { "name": "LiSi", "age": 18, "isStudent": true, "Binary": new Uint8Array([1, 2, 3]) };
let predicates = new dataSharePredicates.DataSharePredicates();
let valArray = new Array("*");
// Insert a piece of data.
dsHelper.insert(dseUri, valuesBucket, (err, data) => {
console.log("dsHelper insert result: " + data);
});
// Delete data.
dsHelper.delete(dseUri, da, (err, data) => {
console.log("dsHelper delete result: " + data);
});
// Update data.
dsHelper.update(dseUri, da, updateBucket, (err, data) => {
dsHelper.update(dseUri, predicates, updateBucket, (err, data) => {
console.log("dsHelper update result: " + data);
});
// Query data.
dsHelper.query(dseUri, da, valArray, (err, data) => {
dsHelper.query(dseUri, predicates, valArray, (err, data) => {
console.log("dsHelper query result: " + data);
});
// Delete data.
dsHelper.delete(dseUri, predicates, (err, data) => {
console.log("dsHelper delete result: " + data);
});
```
......@@ -22,7 +22,7 @@ Before you get started, familiarize yourself with the following concepts:
An application that accesses the data or services provided by a data provider. It is also called a client.
- Value bucket (**ValuesBucket**)
- **ValuesBucket**
One or more data records stored in the form of key-value (KV) pairs. The keys are of the string type. The values can be of the number, string, Boolean, or Unit8Array type.
......
......@@ -12,7 +12,7 @@ The distributed data object management framework provides object-oriented in-mem
- **Distributed data object**
A distributed data object is an encapsulation of the JS object type. Each distributed data object instance creates a data table in the in-memory database. The in-memory databases created for different applications are isolated from each other. Reading data from and writing data to a distributed data object are mapped to the **put** and **get** operations in the corresponding database, respectively.
A distributed data object is an encapsulation of the JS object type. Each distributed data object instance creates a data table in the in-memory database. The in-memory databases created for different applications are isolated from each other. Reading data from and writing data to a distributed data object are mapped to the **get** and **put** operations in the corresponding database, respectively.
The distributed data object can be in the following states in its lifecycle:
......
......@@ -94,9 +94,16 @@ Use the following APIs to delete a **Preferences** instance or data file.
```js
// Obtain the context.
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext()
let context = featureAbility.getContext();
let preferences = null;
let promise = data_preferences.getPreferences(context, 'mystore');
promise.then((pref) => {
preferences = pref;
}).catch((err) => {
console.info("Failed to get the preferences.");
})
```
Stage model:
......@@ -104,14 +111,21 @@ Use the following APIs to delete a **Preferences** instance or data file.
```ts
// Obtain the context.
import Ability from '@ohos.application.Ability'
var context
class MainAbility extends Ability{
let context = null;
let preferences = null;
export default class MainAbility extends Ability {
onWindowStageCreate(windowStage){
context = this.context
context = this.context;
}
}
let promise = data_preferences.getPreferences(context, 'mystore');
promise.then((pref) => {
preferences = pref;
}).catch((err) => {
console.info("Failed to get the preferences.");
})
```
3. Write data.
......@@ -119,16 +133,12 @@ Use the following APIs to delete a **Preferences** instance or data file.
Use the **preferences.put()** method to write data to the **Preferences** instance.
```js
promise.then((preferences) => {
let putPromise = preferences.put('startup', 'auto');
putPromise.then(() => {
console.info("Put the value of 'startup' successfully.");
}).catch((err) => {
console.info("Failed to put the value of 'startup'. Cause: " + err);
})
}).catch((err) => {
console.info("Failed to get the preferences.");
})
```
4. Read data.
......@@ -136,16 +146,12 @@ Use the following APIs to delete a **Preferences** instance or data file.
Use the **preferences.get()** method to read data.
```js
promise.then((preferences) => {
let getPromise = preferences.get('startup', 'default');
getPromise.then((value) => {
console.info("The value of 'startup' is " + value);
}).catch((err) => {
console.info("Failed to get the value of 'startup'. Cause: " + err);
})
}).catch((err) => {
console.info("Failed to get the preferences.")
});
```
5. Store data persistently.
......@@ -161,11 +167,12 @@ Use the following APIs to delete a **Preferences** instance or data file.
Specify an observer as the callback to subscribe to data changes for an application. When the value of the subscribed key is changed and saved by **flush()**, the observer callback will be invoked to return the new data.
```js
var observer = function (key) {
let observer = function (key) {
console.info("The key" + key + " changed.");
}
preferences.on('change', observer);
preferences.put('startup', 'auto', function (err) {
// The data is changed from 'auto' to 'manual'.
preferences.put('startup', 'manual', function (err) {
if (err) {
console.info("Failed to put the value of 'startup'. Cause: " + err);
return;
......
......@@ -140,7 +140,7 @@ You can obtain the distributed table name for a remote device based on the local
| Class | API | Description |
| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| RdbStore | sync(mode: SyncMode, predicates: RdbPredicates): Promise\<Array\<[string, number]>> | Synchronizes data between devices. This API uses a promise to return the result.<br>- **mode**: synchronization mode. **SYNC_MODE_PUSH** means to push data from the local device to a remote device. **SYNC_MODE_PULL** means to pull data from a remote device to the local device.<br>- **predicates**: specifies the data and devices to synchronize.<br>- **string**: device ID. <br>- **number**: synchronization status of that device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure.|
| RdbStore | sync(mode: SyncMode, predicates: RdbPredicates): Promise\<Array\<[string, number]>> | Synchronizes data between devices. This API uses a promise to return the result.<br>- **mode**: synchronization mode. **SYNC_MODE_PUSH** means to push data from the local device to a remote device. **SYNC_MODE_PULL** means to pull data from a remote device to the local device.<br>- **predicates**: specifies the data and devices to synchronize.<br>- **string**: device ID. <br>- **number**: synchronization status of each device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure.|
**Registering an RDB Store Observer**
......
......@@ -22,8 +22,8 @@ import stats from '@ohos.bundleState';
| function queryAppUsagePriorityGroup(callback: AsyncCallback&lt;number&gt;): void | Queries the priority group of this application. This API uses an asynchronous callback to return the result.|
| function queryAppUsagePriorityGroup(): Promise&lt;number&gt;; | Queries the priority group of this application. This API uses a promise to return the result.|
| function isIdleState(bundleName: string, callback: AsyncCallback&lt;boolean&gt;): void | Checks whether the application specified by **bundleName** is in the idle state. |
| function getRecentlyUsedModules(callback: AsyncCallback&lt;BundleActiveModuleInfo&gt;): void | Obtains the number of FA usage records specified by **1000**.|
| function getRecentlyUsedModules(maxNum: number, callback: AsyncCallback&lt;BundleActiveModuleInfo&gt;): void | Obtains the number of FA usage records specified by **maxNum**.|
| function getRecentlyUsedModules(callback: AsyncCallback&lt;BundleActiveModuleInfo&gt;): void | Obtains a maximum of 1000 FA usage records. |
| function getRecentlyUsedModules(maxNum: number, callback: AsyncCallback&lt;BundleActiveModuleInfo&gt;): void | Obtains the number of FA usage records specified by **maxNum**, which cannot exceed 1000.|
| function queryAppNotificationNumber(begin: number, end: number, callback: AsyncCallback&lt;Array&lt;BundleActiveEventState&gt;&gt;): void | Queries the number of notifications from all applications based on the specified start time and end time.|
| function queryBundleActiveEventStates(begin: number, end: number, callback: AsyncCallback&lt;Array&lt;BundleActiveEventState&gt;&gt;): void | Queries statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time.|
| function queryAppUsagePriorityGroup(bundleName : string, callback: AsyncCallback&lt;number&gt;): void | Queries the priority group of the application specified by **bundleName**. This API uses an asynchronous callback to return the result.|
......@@ -326,14 +326,14 @@ import stats from '@ohos.bundleState';
```js
import stats from '@ohos.bundleState'
// Promise mode without parameters
// Promise mode when bundleName is not specified
stats.queryAppUsagePriorityGroup().then(res => {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res));
}).catch(err => {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code);
});
// Asynchronous callback mode without parameters
// Asynchronous callback mode when bundleName is not specified
stats.queryAppUsagePriorityGroup((err, res) => {
if (err) {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code);
......@@ -341,16 +341,16 @@ import stats from '@ohos.bundleState';
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res));
}
});
// Promise mode with parameters
stats.queryAppUsagePriorityGroup(this.bundleName).then(res => {
let bundleName = "com.ohos.camera";
// Promise mode when bundleName is specified
stats.queryAppUsagePriorityGroup(bundleName).then(res => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res));
}).catch(err => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise failed. because: ' + err.code);
});
// Asynchronous callback mode with parameters
stats.queryAppUsagePriorityGroup(this.bundleName, (err, res) => {
// Asynchronous callback mode when bundleName is specified
stats.queryAppUsagePriorityGroup(bundleName, (err, res) => {
if (err) {
console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code);
} else {
......@@ -437,3 +437,4 @@ import stats from '@ohos.bundleState';
}
});
```
......@@ -202,7 +202,7 @@ struct DialogTest {
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
The **\<List>** component is a scrollable container. By default, it taks up the entire screen height. When any component with a fixed height takes up part of the screen height, you need to explicitly specify **layoutWeight(1)** for the parent container of the **\<List>** component to take up the remaining height instead of the entire screen height.
The **\<List>** component is a scrollable container. By default, it takes up the entire screen height. When any component with a fixed height takes up part of the screen height, you need to explicitly specify **layoutWeight(1)** for the parent container of the **\<List>** component to take up the remaining height instead of the entire screen height.
## How do I center child components in a grid container?
......
......@@ -30,7 +30,7 @@ let options = {trim : false, declarationKey:"_declaration",
nameKey : "_name", elementsKey : "_elements"}
let result:any = conv.convert(xml, options) // Convert fields in the XML file into JavaScript objects.
console.log('Test: ' + JSON.stringify(result))
console.log('Test: ' + result._declaration._attributes.version) // vesion field in XML file
console.log('Test: ' + result._declaration._attributes.version) // version field in XML file
console.log('Test: ' + result._elements[0]._elements[0]._elements[0]._text) // title field in XML file
```
......
......@@ -21,45 +21,43 @@ let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: {
// Create a PixelMap object.
const color = new ArrayBuffer(96);
let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 2, width: 3 } }
image.createPixelMap(color, opts, pixelmap => {
expect(pixelmap !== null).assertTrue();
console.info('TC_001-1 success');
done();
})
image.createPixelMap(color, opts, pixelmap => {
console.log('Succeeded in creating pixelmap.');
})
// Read pixels.
pixelmap.readPixels(area,(data) => {
if(data !== null) {
var bufferArr = new Uint8Array(area.pixels);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
console.info('TC_021-1 buffer ' + bufferArr[i]);
console.info(' buffer ' + bufferArr[i]);
if(res) {
if(bufferArr[i] == 0) {
res = false;
console.info('TC_021-1 Success');
expect(true).assertTrue();
done();
console.log('readPixels end.');
break;
}
}
}
}
})
// Store pixels.
const readBuffer = new ArrayBuffer(96);
pixelmap.readPixelsToBuffer(readBuffer,() => {
var bufferArr = new Uint8Array(readBuffer);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
var bufferArr = new Uint8Array(readBuffer);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
if(res) {
if (bufferArr[i] !== 0) {
res = false;
console.info('TC_020-1 Success');
expect(true).assertTrue();
done();
console.log('readPixelsToBuffer end.');
break;
}
}
}
}
})
// Write pixels.
pixelmap.writePixels(area,() => {
......@@ -71,13 +69,13 @@ pixelmap.writePixels(area,() => {
if(res) {
if (readArr[i] !== 0) {
res = false;
console.info('TC_022-1 Success');
expect(true).assertTrue();
done();
console.log('readPixels end.please check buffer');
break;
}
}
}
})
})
// Write pixels to the buffer.
pixelmap.writeBufferToPixels(writeColor).then(() => {
......@@ -89,38 +87,33 @@ pixelmap.writeBufferToPixels(writeColor).then(() => {
if(res) {
if (bufferArr[i] !== i) {
res = false;
console.info('TC_023 Success');
expect(true).assertTrue()
done();
console.log('readPixels end.please check buffer');
break;
}
}
}
})
})
// Obtain image information.
pixelmap.getImageInfo( imageInfo => {
if (imageInfo !== null) {
console.info('TC_024-1 imageInfo is ready');
expect(imageInfo.size.height == 4).assertTrue();
expect(imageInfo.size.width == 6).assertTrue();
expect(imageInfo.pixelFormat == 4).assertTrue();
done();
console.log('Succeeded in getting imageInfo');
}
})
// Release the PixelMap object.
pixelmap.release(()=>{
expect(true).assertTrue();
console.log('TC_027-1 suc');
done();
console.log('Succeeded in releasing pixelmap');
})
let path = '/data/local/tmp/test.jpg';
// Create an image source (uri).
const imageSourceApi = image.createImageSource(path); // '/data/local/tmp/test.jpg'
let path = '/data/local/tmp/test.jpg';
const imageSourceApi = image.createImageSource(path);
// Create an image source (fd).
const imageSourceApi = image.createImageSource(29);
let fd = 29;
const imageSourceApi = image.createImageSource(fd);
// Create an image source (data).
const data = new ArrayBuffer(96);
......@@ -128,15 +121,15 @@ const imageSourceApi = image.createImageSource(data);
// Release the image source.
imageSourceApi.release(() => {
console.info('TC_044-1 Success');
})
console.log('Succeeded in releasing imagesource');
})
// Encode the image.
const imagePackerApi = image.createImagePacker();
const imageSourceApi = image.createImageSource(0);
let packOpts = { format:"image/jpeg", quality:98 };
imagePackerApi.packing(imageSourceApi, packOpts, data => {
console.info('TC_062-1 finished');
expect(data !== null).assertTrue();
done();
console.log('Succeeded in packing');
})
// Release the ImagePacker object.
......@@ -164,59 +157,40 @@ let decodingOptions = {
// Create a pixel map in callback mode.
imageSourceApi.createPixelMap(decodingOptions, pixelmap => {
console.info('TC_050 createPixelMap ');
expect(pixelmap !== null ).assertTrue();
done();
})
}
console.log('Succeeded in creating pixelmap.');
})
// Create a pixel map in promise mode.
imageSourceApi.createPixelMap().then(pixelmap => {
console.info('TC_050-11 createPixelMap ');
expect(pixelmap !== null ).assertTrue();
done();
console.log('Succeeded in creating pixelmap.');
})
// Capture error information when an exception occurs during function invoking.
catch(error => {
console.log('TC_050-11 error: ' + error);
expect().assertFail();
done();
console.log('Failed in creating pixelmap.' + error);
})
// Obtain the number of bytes in each line of pixels.
pixelmap.getBytesNumberPerRow( num => {
console.info('TC_025-1 num is ' + num);
expect(num == expectNum).assertTrue();
done();
console.log('Succeeded in getting BytesNumber PerRow.');
})
// Obtain the total number of pixel bytes.
pixelmap.getPixelBytesNumber(num => {
console.info('TC_026-1 num is ' + num);
expect(num == expectNum).assertTrue();
done();
console.log('Succeeded in getting PixelBytesNumber.');
})
// Obtain the pixel map information.
pixelmap.getImageInfo( imageInfo => {})
// Print the failure information.
console.info('TC_024-1 imageInfo is empty');
expect(false).assertTrue()
// Release the PixelMap object.
pixelmap.release(()=>{
expect(true).assertTrue();
console.log('TC_027-1 suc');
done();
console.log('Succeeded in releasing pixelmap');
})
// Capture release failure information.
catch(error => {
console.log('TC_027-1 error: ' + error);
expect().assertFail();
done();
console.log('Failed in releasing pixelmap.' + error);
})
```
......@@ -230,9 +204,7 @@ const imageSourceApi = image.createImageSource(path); // '/data/local/tmp/test.p
// Print the error message if the image source fails to be created.
if (imageSourceApi == null) {
console.info('TC_062 create image source failed');
expect(false).assertTrue();
done();
console.log('Failed in creating imageSource.');
}
// Create an image packer if the image source is successfully created.
......@@ -240,9 +212,7 @@ const imagePackerApi = image.createImagePacker();
// Print the error information if the image packer fails to be created.
if (imagePackerApi == null) {
console.info('TC_062 create image packer failed');
expect(false).assertTrue();
done();
console.log('Failed in creating imagePacker.');
}
// Set encoding parameters if the image packer is successfully created.
......@@ -252,9 +222,7 @@ let packOpts = { format:["image/jpeg"], // The supported encoding format is jpg.
// Encode the image.
imagePackerApi.packing(imageSourceApi, packOpts)
.then( data => {
console.info('TC_062 finished');
expect(data !== null).assertTrue();
done();
console.log('Succeeded in packing');
})
// Release the image packer after the encoding is complete.
......@@ -262,9 +230,7 @@ imagePackerApi.release();
// Obtain the image source information.
imageSourceApi.getImageInfo(imageInfo => {
console.info('TC_045 imageInfo');
expect(imageInfo !== null).assertTrue();
done();
console.log('Succeeded in getting imageInfo');
})
// Update incremental data.
......
......@@ -17,11 +17,11 @@ You can `import` the native .so that contains the JS processing logic. For examp
### .so Naming Rules
Each module has a .so file. For example, if the module name is `hello`, name the .so file **libhello.so**. The `nm_modname` field in `napi_module` must be `hello`, which is the same as the module name. The sample code for importing the .so file is `import hello from 'libhello.so'`.
Each module has a .so file. For example, if the module name is `hello`, name the .so file `libhello.so`. The `nm_modname` field in `napi_module` must be `hello`, which is the same as the module name. The sample code for importing the .so file is `import hello from 'libhello.so'`.
### JS Objects and Threads
The Ark engine prevents NAPIs from being called to operate JS objects in non-JS threads. Otherwise, the application will crash.
The Ark engine prevents NAPIs from being called to operate JS objects in non-JS threads. Otherwise, the application will crash. Observe the following rules:
* The NAPIs can be used only in JS threads.
* **env** is bound to a thread and cannot be used across threads. The JS object created by a NAPI can be used only in the thread, in which the object is created, that is, the JS object is bound to the **env** of the thread.
......@@ -640,8 +640,3 @@ export default {
}
}
```
## Samples
The following samples are provided for native API development:
- [`NativeAPI`: NativeAPI (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/Native/NativeAPI)
- [First Native C++ Application (eTS) (API9)](https://gitee.com/openharmony/codelabs/tree/master/NativeAPI/NativeTemplateDemo)
- [Native Component (eTS) (API9) ](https://gitee.com/openharmony/codelabs/tree/master/NativeAPI/XComponent)
......@@ -37,9 +37,7 @@ For details about the APIs, see [reminderAgent](../reference/apis/js-apis-remind
import reminderAgent from '@ohos.reminderAgent';
import notification from '@ohos.notification';
export default {
// For a JS project:
// timer: {
// For an eTS project:
// eTS project:
let timer : reminderAgent.ReminderRequestTimer = {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 10,
......@@ -69,9 +67,7 @@ For details about the APIs, see [reminderAgent](../reference/apis/js-apis-remind
Sample code for defining a reminder agent for a calendar event:
```js
// For a JS project:
// calendar: {
// For an eTS project:
// eTS project:
let calendar : reminderAgent.ReminderRequestCalendar = {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_CALENDAR,
dateTime: {
......@@ -117,9 +113,7 @@ For details about the APIs, see [reminderAgent](../reference/apis/js-apis-remind
Sample code for defining a reminder agent for an alarm:
```js
// For a JS project:
// alarm: {
// For an eTS project:
// eTS project:
let alarm : reminderAgent.ReminderRequestAlarm = {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_ALARM,
hour: 11,
......@@ -171,4 +165,3 @@ For details about the APIs, see [reminderAgent](../reference/apis/js-apis-remind
<button type="text" value="publishReminder" onclick="startTimer"></button>
</div>
```
......@@ -13,14 +13,14 @@ Each application can subscribe to common events as required. After your applicat
## Common Event Subscription Development
### When to Use
You can create a subscriber object to subscribe to a common event to obtain the parameters passed in the event. Certain system common events require specific permissions to subscribe to. For details, see [Required Permissions](../reference/apis/js-apis-commonEvent.md).
You can create a subscriber object to subscribe to a common event to obtain the parameters passed in the event. Certain system common events require specific permissions to subscribe to. For details, see [Required Permissions](../reference/apis/js-apis-commonEvent.md#support).
### Available APIs
| API | Description|
| ---------------------------------------------------------------------------------------------- | ----------- |
| commonEvent.createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback) | Creates a subscriber. This API uses a callback to return the result.|
| commonEvent.createSubscriber(subscribeInfo: CommonEventSubscribeInfo) | Creates a subscriber. This API uses a promise to return the result. |
| commonEvent.subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback) | Subscribes to common events.|
| createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback) | Creates a subscriber. This API uses a callback to return the result.|
| createSubscriber(subscribeInfo: CommonEventSubscribeInfo) | Creates a subscriber. This API uses a promise to return the result. |
| subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback) | Subscribes to common events.|
### How to Develop
1. Import the **commonEvent** module.
......@@ -82,8 +82,8 @@ You can use the **publish** APIs to publish a custom common event, which can car
### Available APIs
| API | Description|
| ---------------------------------- | ------ |
| commonEvent.publish(event: string, callback: AsyncCallback) | Publishes a common event.|
| commonEvent.publish(event: string, options: CommonEventPublishData, callback: AsyncCallback) | Publishes a common event with given attributes.|
| publish(event: string, callback: AsyncCallback) | Publishes a common event.|
| publish(event: string, options: CommonEventPublishData, callback: AsyncCallback) | Publishes a common event with given attributes.|
### How to Develop
#### Development for Publishing a Common Event
......@@ -119,7 +119,7 @@ import commonEvent from '@ohos.commonEvent'
// Attributes of a common event.
var options = {
code: 1, // Result code of the common event
data: "initial data",// Result data of the common event
data: "initial data";// Result data of the common event
}
```
......@@ -144,7 +144,7 @@ You can use the **unsubscribe** API to unsubscribe from a common event.
### Available APIs
| API | Description|
| ---------------------------------- | ------ |
| commonEvent.unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback) | Unsubscribes from a common event.|
| unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback) | Unsubscribes from a common event.|
### How to Develop
1. Import the **commonEvent** module.
......@@ -153,7 +153,7 @@ You can use the **unsubscribe** API to unsubscribe from a common event.
import commonEvent from '@ohos.commonEvent';
```
2. Subscribe to a common event by following instructions in [Common Event Subscription Development](#Common-Event-Subscription-Development).
2. Subscribe to a common event by following instructions in [Common Event Subscription Development](#common-event-subscription-development).
3. Invoke the **unsubscribe** API in **CommonEvent** to unsubscribe from the common event.
```js
......
......@@ -7,16 +7,13 @@ Common Event Service (CES) enables applications to publish, subscribe to, and un
![ces](figures/ces.png)
- System common event: sent by the system based on system policies to the applications that have subscribed to the event. This type of event includes the screen-on/off events that the users are aware of and the system events published by key system services, such as USB device attachment or detachment, network connection, and system update events.
- Custom common event: customized by applications to be received by specific subscribers. This type of event is usually related to the service logic of the sender applications.
The Advanced Notification Service (ANS) enables applications to publish notifications. Below are some typical use cases for publishing notifications:
- Display received SMS messages and instant messages.
- Display push messages of applications, such as advertisements, version updates, and news notifications.
The Advanced Notification Service (ANS) enables applications to publish notifications. Below are some typical use cases for publishing notifications:
- Display ongoing events, such as music playback, navigation information, and download progress.
- Display received SMS messages and instant messages.
- Display push messages of applications, such as advertisements, version updates, and news notifications.
- Display ongoing events, such as music playback, navigation information, and download progress.
Notifications are displayed in the notification panel. Uses can delete a notification or click the notification to trigger predefined actions.
......
......@@ -139,6 +139,80 @@ bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => {
})
```
## bundle.getApplicationInfoSync<sup>9+</sup>
getApplicationInfoSync(bundleName: string, bundleFlags: number, userId: number): ApplicationInfo;
Obtains the application information of the specified user based on a given bundle name. This API returns the result synchronously.
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**System capability**
SystemCapability.BundleManager.BundleFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ------------------------------------------------------------ |
| bundleName | string | Yes | Bundle name of an application. |
| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
**Return value**
| Type | Description |
| ---------------------------------------------------- | ------------------- |
| [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | **ApplicationInfo** object.|
**Example**
```js
let bundleName = "com.example.myapplication";
let bundleFlags = 0;
let userId = 100;
var applicationInfo = bundle.getApplicationInfoSync(bundleName, bundleFlags, userId);
console.info('Operation successful. Name:' + applicationInfo.name);
```
## bundle.getApplicationInfoSync<sup>9+</sup>
getApplicationInfoSync(bundleName: string, bundleFlags: number) : ApplicationInfo;
Obtains the application information based on a given bundle name. This API returns the result synchronously.
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**System capability**
SystemCapability.BundleManager.BundleFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ------------------------------------------------------------ |
| bundleName | string | Yes | Bundle name of an application. |
| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
**Return value**
| Type | Description |
| ---------------------------------------------------- | ------------------- |
| [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | **ApplicationInfo** object.|
**Example**
```js
let bundleName = "com.example.myapplication";
let bundleFlags = 0;
var applicationInfo = bundle.getApplicationInfoSync(bundleName, bundleFlags);
console.info('Operation successful. Name:' + applicationInfo.name);
```
## bundle.getAllBundleInfo
getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise<Array\<BundleInfo>>
......@@ -370,6 +444,82 @@ bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => {
})
```
## bundle.getBundleInfoSync<sup>9+</sup>
getBundleInfoSync(bundleName: string, bundleFlags: number, options: BundleOptions): BundleInfo;
Obtains the bundle information based on a given bundle name and bundle options. This API returns the result synchronously.
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**System capability**
SystemCapability.BundleManager.BundleFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| bundleName | string | Yes | Bundle name of an application. |
| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
| options | [BundleOptions](#bundleoptions) | Yes | Options of the bundle. |
**Return value**
| Type | Description |
| ------------------------------------------ | -------------- |
| [BundleInfo](js-apis-bundle-BundleInfo.md) | **BundleInfo** object.|
**Example**
```js
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
let options = {
"userId" : 100
};
var bundleInfo = bundle.getBundleInfoSync(bundleName, bundleFlags, options);
console.info('Operation successful. Name:' + bundleInfo.name);
```
## bundle.getBundleInfoSync<sup>9+</sup>
getBundleInfoSync(bundleName: string, bundleFlags: number): BundleInfo;
Obtains the bundle information based on a given bundle name. This API returns the result synchronously.
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
**System capability**
SystemCapability.BundleManager.BundleFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ------------------------------------------------------------ |
| bundleName | string | Yes | Bundle name of an application. |
| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
**Return value**
| Type | Description |
| ------------------------------------------ | -------------- |
| [BundleInfo](js-apis-bundle-BundleInfo.md) | **BundleInfo** object.|
**Example**
```js
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
var bundleInfo = bundle.getBundleInfoSync(bundleName, bundleFlags);
console.info('Operation successful. Name:' + bundleInfo.name);
```
## bundle.getBundleInstaller
getBundleInstaller(): Promise&lt;BundleInstaller&gt;;
......@@ -759,7 +909,7 @@ This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------------- | ---------------------------------- | ---- | ---------------------------------------------------- |
| -------------- | ------------------------------------------------------------ | ---- | ---------------------------------------------------- |
| bundleName | string | Yes | Bundle name of an application. |
| bundlePackFlag | pack.BundlePackFlag | Yes | Flags of the bundle package. |
| callback | AsyncCallback<pack.BundlePackInfo> | Yes | Callback used to return the bundle package information.|
......@@ -781,15 +931,15 @@ This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------------- | ------------------- | ---- | ---------------------- |
| -------------- | ------------------------------------------------- | ---- | ---------------------- |
| bundleName | string | Yes | Bundle name of an application. |
| bundlePackFlag | pack.BundlePackFlag | Yes | Flags of the bundle package.|
**Return value**
| Type | Description |
| ---------------------------- | ----------------------------------- |
| Promise<pack.BundlePackInfo> | Promise used to return the bundle package information.|
| ---------------------------- | ------------------------------------------------------ |
| Promise<pack.BundlePackInfo> | Promise used to return the bundle package information. |
## bundle.getDispatcherVersion<sup>9+</sup>
......
......@@ -49,3 +49,51 @@ export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbil
}
};
```
## EnterpriseAdminExtensionAbility.onBundleAdded
onBundleAdded(bundleName: string): void
Called when a bundle is added.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**Parameters**
| Parameter | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| bundleName | string | Yes | Name of the bundle added.|
**Example**
```ts
export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
onBundleAdded(bundleName: string) {
console.log("added bundle name: " + bundleName);
}
};
```
## EnterpriseAdminExtensionAbility.onBundleRemoved
onBundleRemoved(bundleName: string): void
Called when a bundle is removed.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**Parameters**
| Parameter | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| bundleName | string | Yes | Name of the bundle removed.|
**Example**
```ts
export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
onBundleAdded(bundleName: string) {
console.log("removed bundle name: " + bundleName);
}
};
```
# System Accessibility Configuration
The **config** module allows you to configure system accessibility features, including accessibility extension, high-contrast text, mouse buttons, and captions.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
## Modules to Import
```typescript
import config from "@ohos.accessibility.config";
```
## Attributes
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| highContrastText | [Config](#config)\<boolean>| Yes| Yes| Whether to enable high-contrast text.|
| invertColor | [Config](#config)\<boolean>| Yes| Yes| Whether to enable color inversion.|
| daltonizationColorFilter | [Config](#config)&lt;[DaltonizationColorFilter](#daltonizationcolorfilter)&gt;| Yes| Yes| Configuration of the daltonization filter.|
| contentTimeout | [Config](#config)\<number>| Yes| Yes| Recommended duration for content display. The value ranges from 0 to 5000, in milliseconds.|
| animationOff | [Config](#config)\<boolean>| Yes| Yes| Whether to enable animation.|
| brightnessDiscount | [Config](#config)\<number>| Yes| Yes| Brightness discount. The value ranges from 0 to 1.0.|
| mouseKey | [Config](#config)\<boolean>| Yes| Yes| Whether to enable the mouse button feature.|
| mouseAutoClick | [Config](#config)\<number>| Yes| Yes| Interval for the automatic mouse clicks. The value ranges from 0 to 5000, in milliseconds.|
| shortkey | [Config](#config)\<boolean>| Yes| Yes| Whether to enable the accessibility extension shortcut key.|
| shortkeyTarget | [Config](#config)\<string>| Yes| Yes| Target application for the accessibility extension shortcut key. The value format is bundleName/abilityName.|
| captions | [Config](#config)\<boolean>| Yes| Yes| Whether to enable captions.|
| captionsStyle | [Config](#config)\<[accessibility.CaptionsStyle](./js-apis-accessibility.md#captionsstyle8)>| Yes| Yes| Captions style.|
## enableAbility
enableAbility(name: string, capability: Array&lt;[accessibility.Capability](./js-apis-accessibility.md#capability)&gt;): Promise&lt;void&gt;;
Enables an accessibility extension ability. This API uses a promise to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the accessibility extension ability. The format is bundleName/abilityName.|
| capability | Array&lt;[accessibility.Capability](./js-apis-accessibility.md#capability)&gt;) | Yes| Capability of the accessibility extension ability.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
**Example**
```typescript
config.enableAbility("com.ohos.example/axExtension", ['retrieve'])
.then(() => {
console.info('enable succeed');
}).catch((error) => {
console.error('enable failed');
});
```
## enableAbility
enableAbility(name: string, capability: Array&lt;[accessibility.Capability](./js-apis-accessibility.md#capability)&gt;, callback: AsyncCallback&lt;void&gt;): void;
Enables an accessibility extension ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the accessibility extension ability. The format is bundleName/abilityName.|
| capability | Array&lt;[accessibility.Capability](./js-apis-accessibility.md#capability)&gt; | Yes| Capability of the accessibility extension ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.|
**Example**
```typescript
config.enableAbility("com.ohos.example/axExtension", ['retrieve'], (err, data) => {
if (err) {
console.error('enable failed');
return;
}
console.info('enable succeed');
})
```
## disableAbility
disableAbility(name: string): Promise&lt;void&gt;;
Disables an accessibility extension ability. This API uses a promise to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the accessibility extension ability. The format is bundleName/abilityName.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
**Example**
```typescript
config.disableAbility("com.ohos.example/axExtension")
.then(() => {
console.info('disable succeed');
}).catch((error) => {
console.error('disable failed');
});
```
## disableAbility
disableAbility(name: string, callback: AsyncCallback&lt;void&gt;): void;
Disables an accessibility extension ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the accessibility extension ability. The format is bundleName/abilityName.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.|
**Example**
```typescript
config.disableAbility("com.ohos.example/axExtension", (err, data) => {
if (err) {
console.error('disable failed');
return;
}
console.info('disable succeed');
})
```
## on('enableAbilityListsStateChanged')
on(type: 'enableAbilityListsStateChanged', callback: Callback&lt;void&gt;): void;
Adds a listener for changes in the list of enabled accessibility extension abilities.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Listening type. The value is fixed at **'enableAbilityListsStateChanged'**, indicating that the changes in the list of enabled accessibility extension abilities.|
| callback | Callback&lt;void&gt; | Yes| Callback invoked when the list of enabled accessibility extension abilities changes.|
**Example**
```typescript
config.on('enableAbilityListsStateChanged',() => {
console.info('ax extension ability enable list changed');
});
```
## off('enableAbilityListsStateChanged')
off(type: 'enableAbilityListsStateChanged', callback?: Callback&lt;void&gt;): void;
Cancels the listener for changes in the list of enabled accessibility extension abilities.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | No| Listening type. The value is fixed at **'enableAbilityListsStateChanged'**, indicating that the changes in the list of enabled accessibility extension abilities.|
| callback | Callback&lt;void&gt; | No| Callback invoked when the list of enabled accessibility extension abilities changes.|
**Example**
```typescript
config.off('enableAbilityListsStateChanged');
```
## Config
Implements configuration, acquisition, and listening for attributes.
### set
set(value: T): Promise&lt;void&gt;;
Sets this attribute. This API uses a promise to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | Yes| Attribute value to set.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
**Example**
```typescript
config.highContrastText.set(true)
.then(() => {
console.info('highContrastText set succeed');
}).catch((error) => {
console.error('highContrastText set failed');
});
```
### set
set(value: T, callback: AsyncCallback&lt;void&gt;): void;
Sets this attribute. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | Yes| Attribute value to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.|
**Example**
```typescript
config.highContrastText.set(true, (err, data) => {
if (err) {
console.error('highContrastText set failed');
return;
}
console.info('highContrastText set succeed');
})
```
### get
get(): Promise&lt;T&gt;;
Obtains the value of this attribute. This API uses a promise to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;T&gt; | Promise used to return the attribute value.|
**Example**
```typescript
config.highContrastText.get()
.then((value) => {
console.info('highContrastText get succeed');
}).catch((error) => {
console.error('highContrastText get failed');
});
```
### get
get(callback: AsyncCallback&lt;T&gt;): void;
Obtains the value of this attribute. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the attribute value.|
**Example**
```typescript
config.highContrastText.get((err, data) => {
if (err) {
console.error('highContrastText get failed');
return;
}
console.info('highContrastText get succeed');
})
```
### on
on(callback: Callback&lt;T&gt;): void;
Adds a listener for attribute changes.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | Callback&lt;T&gt; | Yes| Callback invoked when the attribute changes.|
**Example**
```typescript
config.highContrastText.on(() => {
console.info('highContrastText changed');
});
```
### off
off(callback?: Callback&lt;T&gt;): void;
Cancels the listener for attribute changes.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | Callback&lt;T&gt; | No| Callback invoked when the attribute changes.|
**Example**
```typescript
config.highContrastText.off();
```
## DaltonizationColorFilter
Enumerates the daltonization filters.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
| Name| Description|
| -------- | -------- |
| Normal | Filter for normal users.|
| Protanomaly | Filter for protanomaly.|
| Deuteranomaly | Filter for deuteranomaly.|
| Tritanomaly | Filter for tritanomaly.|
......@@ -14,9 +14,9 @@ The mission snapshot information can be obtained by using **getMissionSnapShot**
```js
import ElementName from '@ohos.bundle';
import image from '@ohos.multimedia.image';
import missionManager from '@ohos.application.missionManager'
import missionManager from '@ohos.application.missionManager';
missionManager.getMissionInfos("", 10, (error, missions) => {
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
......@@ -26,7 +26,7 @@ import missionManager from '@ohos.application.missionManager'
console.log("getMissionSnapShot is called, error.code = " + error.code);
console.log("bundleName = " + snapshot.ability.bundleName);
})
})
})
```
## MissionSnapshot
......
......@@ -16,6 +16,16 @@ import buffer from '@ohos.buffer';
## Buffer
### Attributes
**System capability**: SystemCapability.Utils.Lang
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| length | number | Yes| No| Length of the buffer, in bytes.|
| buffer | ArrayBuffer | Yes| No| **ArrayBuffer** object.|
| byteOffset | number | Yes| No| Offset of the buffer in the memory pool.|
### alloc
alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer
......@@ -2422,7 +2432,7 @@ Creates a **Blob** instance by copying specified data from this **Blob** instanc
let blob3 = blob.slice(0, 2, "MIME");
```
### text
### text
text(): Promise&lt;string&gt;
......
......@@ -195,7 +195,7 @@ Moves to the specified row in the result set.
**Example**
```ts
let goToRowNum = 2
let goToRowNum = 2;
let isGoToRow = resultSet.goToRow(goToRowNum);
console.info('resultSet.goToRow: ' + isGoToRow);
```
......@@ -223,7 +223,7 @@ Obtains the value in the form of a byte array based on the specified column and
**Example**
```ts
let columnIndex = 1
let columnIndex = 1;
let goToFirstRow = resultSet.goToFirstRow();
let getBlob = resultSet.getBlob(columnIndex);
console.info('resultSet.getBlob: ' + getBlob);
......@@ -231,7 +231,7 @@ console.info('resultSet.getBlob: ' + getBlob);
### getString
getString(columnIndex: number): *string*
getString(columnIndex: number): string
Obtains the value in the form of a string based on the specified column and the current row.
......@@ -252,7 +252,7 @@ Obtains the value in the form of a string based on the specified column and the
**Example**
```ts
let columnIndex = 1
let columnIndex = 1;
let goToFirstRow = resultSet.goToFirstRow();
let getString = resultSet.getString(columnIndex);
console.info('resultSet.getString: ' + getString);
......@@ -281,7 +281,7 @@ Obtains the value in the form of a long integer based on the specified column an
**Example**
```ts
let columnIndex = 1
let columnIndex = 1;
let goToFirstRow = resultSet.goToFirstRow();
let getLong = resultSet.getLong(columnIndex);
console.info('resultSet.getLong: ' + getLong);
......@@ -310,7 +310,7 @@ Obtains the value in the form of a double-precision floating-point number based
**Example**
```ts
let columnIndex = 1
let columnIndex = 1;
let goToFirstRow = resultSet.goToFirstRow();
let getDouble = resultSet.getDouble(columnIndex);
console.info('resultSet.getDouble: ' + getDouble);
......@@ -353,14 +353,14 @@ Obtains the column index based on the column name.
**Example**
```ts
let ColumnName = "name"
let getColumnIndex = resultSet.getColumnIndex(ColumnName)
let ColumnName = "name";
let getColumnIndex = resultSet.getColumnIndex(ColumnName);
console.info('resultSet.getColumnIndex: ' + getColumnIndex);
```
### getColumnName
getColumnName(columnIndex: number): *string*
getColumnName(columnIndex: number): string
Obtains the column name based on the column index.
......@@ -381,8 +381,8 @@ Obtains the column name based on the column index.
**Example**
```ts
let columnIndex = 1
let getColumnName = resultSet.getColumnName(columnIndex)
let columnIndex = 1;
let getColumnName = resultSet.getColumnName(columnIndex);
console.info('resultSet.getColumnName: ' + getColumnName);
```
......
......@@ -2,6 +2,8 @@
You can use **DataSharePredicates** to specify conditions for [updating](js-apis-data-dataShare.md#update), [deleting](js-apis-data-dataShare.md#delete), and [querying](js-apis-data-dataShare.md#query) data when **DataShare** is used to manage data.
The APIs provided by **DataSharePredicates** correspond to the filter criteria of the database. Before using the APIs, you need to have basic database knowledge.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -22,7 +24,7 @@ Provides methods for setting different **DataSharePredicates** objects.
equalTo(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to match the data that is equal to the specified value.
Sets a **DataSharePredicates** object to search for the data that is equal to the specified value.
Currently, only the relational database (RDB) and key-value database (KVDB, schema) support this **DataSharePredicates** object.
......@@ -52,7 +54,7 @@ predicates.equalTo("NAME", "Rose")
notEqualTo(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to match the data that is not equal to the specified value.
Sets a **DataSharePredicates** object to search for the data that is not equal to the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
......@@ -188,7 +190,7 @@ predicates.equalTo("NAME", "lisi")
contains(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to match the data that contains the specified value.
Sets a **DataSharePredicates** object to search for the data that contains the specified value.
Currently, only the RDB supports this **DataSharePredicates** object.
......@@ -218,7 +220,7 @@ predicates.contains("NAME", "os")
beginsWith(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to match the data that begins with the specified value.
Sets a **DataSharePredicates** object to search for the data that begins with the specified value.
Currently, only the RDB supports this **DataSharePredicates** object.
......@@ -248,7 +250,7 @@ predicates.beginsWith("NAME", "os")
endsWith(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to match the data that ends with the specified value.
Sets a **DataSharePredicates** object to search for the data that ends with the specified value.
Currently, only the RDB supports this **DataSharePredicates** object.
......@@ -278,7 +280,7 @@ predicates.endsWith("NAME", "os")
isNull(field: string): DataSharePredicates
Sets a **DataSharePredicates** object to match the data whose value is null.
Sets a **DataSharePredicates** object to search for the data whose value is null.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
......@@ -307,7 +309,7 @@ predicates.isNull("NAME")
isNotNull(field: string): DataSharePredicates
Sets a **DataSharePredicates** object to match the data whose value is not null.
Sets a **DataSharePredicates** object to search for the data whose value is not null.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
......@@ -336,7 +338,7 @@ predicates.isNotNull("NAME")
like(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to match the data that is similar to the specified value.
Sets a **DataSharePredicates** object to search for the data that matches the specified wildcard expression.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
......@@ -347,7 +349,7 @@ Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** o
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------- |
| field | string | Yes | Column name in the database table. |
| value | string | Yes | Value to match.|
| value | string | Yes | Wildcard expression to match.<br>In the expression, '%' represents zero, one, or more digits or characters, and '_' represents a single digit or character. It is case insensitive.|
**Return value**
......@@ -366,7 +368,7 @@ predicates.like("NAME", "%os%")
unlike(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to match the data that is not not similar to the specified value.
Sets a **DataSharePredicates** object to search for the data that does not match the specified wildcard expression.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
......@@ -377,7 +379,7 @@ Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** o
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------- |
| field | string | Yes | Column name in the database table. |
| value | string | Yes | Value to match.|
| value | string | Yes | Wildcard expression to match.<br>In the expression, '%' represents zero, one, or more digits or characters, and '_' represents a single digit or character. It is case insensitive.|
**Return value**
......@@ -396,7 +398,7 @@ predicates.unlike("NAME", "%os%")
glob(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to match the specified string.
Sets a **DataSharePredicates** object to search for the data that matches the specified wildcard expression.
Currently, only the RDB supports this **DataSharePredicates** object.
......@@ -407,7 +409,7 @@ Currently, only the RDB supports this **DataSharePredicates** object.
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------- |
| field | string | Yes | Column name in the database table. |
| value | string | Yes | Value to match.|
| value | string | Yes | Wildcard expression to match.<br>In the expression, '*' represents zero, one, or more digits or characters, and '?' represents a single digit or character. It is case sensitive.|
**Return value**
......@@ -426,7 +428,7 @@ predicates.glob("NAME", "?h*g")
between(field: string, low: ValueType, high: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to match the data that is within the specified range.
Sets a **DataSharePredicates** object to search for the data that is within the specified range, including the start and end values.
Currently, only the RDB supports this **DataSharePredicates** object.
......@@ -457,7 +459,7 @@ predicates.between("AGE", 10, 50)
notBetween(field: string, low: ValueType, high: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to match the data that is out of the specified range.
Sets a **DataSharePredicates** object to search for the data that is out of the specified range, excluding the start and end values.
Currently, only the RDB supports this **DataSharePredicates** object.
......@@ -488,7 +490,7 @@ predicates.notBetween("AGE", 10, 50)
greaterThan(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to match the data that is greater than the specified value.
Sets a **DataSharePredicates** object to search for the data that is greater than the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
......@@ -518,7 +520,7 @@ predicates.greaterThan("AGE", 10)
lessThan(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to match the data that is less than the specified value.
Sets a **DataSharePredicates** object to search for the data that is less than the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
......@@ -548,7 +550,7 @@ predicates.lessThan("AGE", 50)
greaterThanOrEqualTo(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to match the data that is greater than or equal to the specified value.
Sets a **DataSharePredicates** object to search for the data that is greater than or equal to the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
......@@ -578,7 +580,7 @@ predicates.greaterThanOrEqualTo("AGE", 10)
lessThanOrEqualTo(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to match the data that is less than or equal to the specified value.
Sets a **DataSharePredicates** object to search for the data that is less than or equal to the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
......@@ -777,7 +779,7 @@ predicates.indexedBy("SALARY_INDEX")
in(field: string, value: Array&lt;ValueType&gt;): DataSharePredicates
Sets a **DataSharePredicates** object to match the data that is within the specified value.
Sets a **DataSharePredicates** object to search for the data that is within the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
......@@ -807,7 +809,7 @@ predicates.in("AGE", [18, 20])
notIn(field: string, value: Array&lt;ValueType&gt;): DataSharePredicates
Sets a **DataSharePredicates** object to match the data that is not in the specified value.
Sets a **DataSharePredicates** object to search for the data that is not in the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
......@@ -837,7 +839,7 @@ predicates.notIn("NAME", ["Lisa", "Rose"])
prefixKey(prefix: string): DataSharePredicates
Sets a **DataSharePredicates** object to match the data with the specified key prefix.
Sets a **DataSharePredicates** object to search for the data with the specified key prefix.
Currently, only the KVDB supports this **DataSharePredicates** object.
......@@ -866,7 +868,7 @@ predicates.prefixKey("NAME")
inKeys(keys: Array&lt;string&gt;): DataSharePredicates
Sets a **DataSharePredicates** object to match the data whose keys are within the given range.
Sets a **DataSharePredicates** object to search for the data whose keys are within the given range.
Currently, only the KVDB supports this **DataSharePredicates** object.
......
......@@ -6,26 +6,25 @@ A result set is a set of results returned after the relational database (RDB) qu
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Usage
You need to use [RdbStore.query()](js-apis-data-rdb.md#query) to obtain a **resultSet** object.
```js
import dataRdb from '@ohos.data.rdb';
let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("AGE", 18)
let promise = rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"])
let predicates = new dataRdb.RdbPredicates("EMPLOYEE");
predicates.equalTo("AGE", 18);
let promise = rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
promise.then((resultSet) => {
console.log(TAG + "resultSet columnNames:" + resultSet.columnNames);
console.log(TAG + "resultSet columnCount:" + resultSet.columnCount);})
console.log(TAG + "resultSet columnCount:" + resultSet.columnCount);
});
```
## ResultSet
Provides methods to access the result set, which is obtained by querying the RDB store.
### Attributes
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
......@@ -42,7 +41,6 @@ Provides methods to access the result set, which is obtained by querying the RDB
| isStarted | boolean | Yes| Whether the cursor has been moved.|
| isClosed | boolean | Yes| Whether the result set is closed.|
### getColumnIndex
getColumnIndex(columnName: string): number
......@@ -52,25 +50,27 @@ Obtains the column index based on the column name.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| columnName | string | Yes| Column name specified.|
**Return value**
| Type| Description|
| -------- | -------- |
| number | Index of the column obtained.|
**Example**
```js
resultSet.goToFirstRow()
const id = resultSet.getLong(resultSet.getColumnIndex("ID"))
const name = resultSet.getString(resultSet.getColumnIndex("NAME"))
const age = resultSet.getLong(resultSet.getColumnIndex("AGE"))
const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"))
resultSet.goToFirstRow();
const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
```
### getColumnName
getColumnName(columnIndex: number): string
......@@ -80,23 +80,25 @@ Obtains the column name based on the column index.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| columnIndex | number | Yes| Column index specified.|
**Return value**
| Type| Description|
| -------- | -------- |
| string | Column name obtained.|
**Example**
```js
const id = resultSet.getColumnName(0)
const name = resultSet.getColumnName(1)
const age = resultSet.getColumnName(2)
const id = resultSet.getColumnName(0);
const name = resultSet.getColumnName(1);
const age = resultSet.getColumnName(2);
```
### goTo
goTo(offset:number): boolean
......@@ -106,28 +108,30 @@ Moves the cursor to the row based on the specified offset.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| offset | number | Yes| Offset relative to the current position.|
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```js
let predicatesgoto = new dataRdb.RdbPredicates("EMPLOYEE")
let promisequerygoto = rdbStore.query(predicatesgoto, ["ID", "NAME", "AGE", "SALARY", "CODES"])
let predicatesgoto = new dataRdb.RdbPredicates("EMPLOYEE");
let promisequerygoto = rdbStore.query(predicatesgoto, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
promisequerygoto.then((resultSet) {
resultSet.goTo(1)
resultSet.close()
resultSet.goTo(1);
resultSet.close();
}).catch((err) => {
console.log('query failed')
})
console.log('query failed');
});
```
### goToRow
goToRow(position: number): boolean
......@@ -137,28 +141,30 @@ Moves the cursor to the specified row in the result set.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| position | number | Yes| Position to which the cursor is to be moved.|
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```js
let predicatesgotorow = new dataRdb.RdbPredicates("EMPLOYEE")
let promisequerygotorow = rdbStore.query(predicatesgotorow, ["ID", "NAME", "AGE", "SALARY", "CODES"])
let predicatesgotorow = new dataRdb.RdbPredicates("EMPLOYEE");
let promisequerygotorow = rdbStore.query(predicatesgotorow, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
promisequerygotorow.then((resultSet) {
resultSet.goToRow(5)
resultSet.close()
resultSet.goToRow(5);
resultSet.close();
}).catch((err) => {
console.log('query failed')
})
console.log('query failed');
});
```
### goToFirstRow
goToFirstRow(): boolean
......@@ -169,23 +175,24 @@ Moves the cursor to the first row of the result set.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```js
let predicatesgoFirst = new dataRdb.RdbPredicates("EMPLOYEE")
let promisequerygoFirst = rdbStore.query(predicatesgoFirst, ["ID", "NAME", "AGE", "SALARY", "CODES"])
let predicatesgoFirst = new dataRdb.RdbPredicates("EMPLOYEE");
let promisequerygoFirst = rdbStore.query(predicatesgoFirst, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
promisequerygoFirst.then((resultSet) {
resultSet.goToFirstRow()
resultSet.close()
resultSet.goToFirstRow();
resultSet.close();
}).catch((err) => {
console.log('query failed')
})
console.log('query failed');
});
```
### goToLastRow
goToLastRow(): boolean
......@@ -195,23 +202,24 @@ Moves the cursor to the last row of the result set.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```js
let predicatesgoLast = new dataRdb.RdbPredicates("EMPLOYEE")
let promisequerygoLast = rdbStore.query(predicatesgoLast, ["ID", "NAME", "AGE", "SALARY", "CODES"])
let predicatesgoLast = new dataRdb.RdbPredicates("EMPLOYEE");
let promisequerygoLast = rdbStore.query(predicatesgoLast, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
promisequerygoLast.then((resultSet) {
resultSet.goToLastRow()
resultSet.close()
resultSet.goToLastRow();
resultSet.close();
}).catch((err) => {
console.log('query failed')
})
console.log('query failed');
});
```
### goToNextRow
goToNextRow(): boolean
......@@ -221,23 +229,24 @@ Moves the cursor to the next row in the result set.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```js
let predicatesgoNext = new dataRdb.RdbPredicates("EMPLOYEE")
let promisequerygoNext = rdbStore.query(predicatesgoNext, ["ID", "NAME", "AGE", "SALARY", "CODES"])
let predicatesgoNext = new dataRdb.RdbPredicates("EMPLOYEE");
let promisequerygoNext = rdbStore.query(predicatesgoNext, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
promisequerygoNext.then((resultSet) {
resultSet.goToNextRow()
resultSet.close()
resultSet.goToNextRow();
resultSet.close();
}).catch((err) => {
console.log('query failed')
})
console.log('query failed');
});
```
### goToPreviousRow
goToPreviousRow(): boolean
......@@ -247,23 +256,24 @@ Moves the cursor to the previous row in the result set.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```js
let predicatesgoPrev = new dataRdb.RdbPredicates("EMPLOYEE")
let promisequerygoPrev = rdbStore.query(predicatesgoPrev, ["ID", "NAME", "AGE", "SALARY", "CODES"])
let predicatesgoPrev = new dataRdb.RdbPredicates("EMPLOYEE");
let promisequerygoPrev = rdbStore.query(predicatesgoPrev, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
promisequerygoPrev.then((resultSet) {
resultSet.goToPreviousRow()
resultSet.close()
resultSet.goToPreviousRow();
resultSet.close();
}).catch((err) => {
console.log('query failed')
})
console.log('query failed');
});
```
### getBlob
getBlob(columnIndex: number): Uint8Array
......@@ -273,21 +283,23 @@ Obtains the value in the specified column in the current row as a byte array.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| columnIndex | number | Yes| Index of the specified column, starting from 0.|
**Return value**
| Type| Description|
| -------- | -------- |
| Uint8Array | Value in the specified column as a byte array.|
**Example**
```js
const codes = resultSet.getBlob(resultSet.getColumnIndex("CODES"))
const codes = resultSet.getBlob(resultSet.getColumnIndex("CODES"));
```
### getString
getString(columnIndex: number): string
......@@ -297,21 +309,23 @@ Obtains the value in the specified column in the current row as a string.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| columnIndex | number | Yes| Index of the specified column, starting from 0.|
**Return value**
| Type| Description|
| -------- | -------- |
| string | Value in the specified column as a string.|
**Example**
```js
const name = resultSet.getString(resultSet.getColumnIndex("NAME"))
const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
```
### getLong
getLong(columnIndex: number): number
......@@ -321,21 +335,23 @@ Obtains the value in the specified column in the current row as a Long.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| columnIndex | number | Yes| Index of the specified column, starting from 0.|
**Return value**
| Type| Description|
| -------- | -------- |
| number | Value in the specified column as a Long.|
**Example**
```js
const age = resultSet.getLong(resultSet.getColumnIndex("AGE"))
const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
```
### getDouble
getDouble(columnIndex: number): number
......@@ -345,21 +361,23 @@ Obtains the value in the specified column in the current row as a double.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| columnIndex | number | Yes| Index of the specified column, starting from 0.|
**Return value**
| Type| Description|
| -------- | -------- |
| number | Value in the specified column as a double.|
**Example**
```js
const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"))
const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
```
### isColumnNull
isColumnNull(columnIndex: number): boolean
......@@ -369,21 +387,23 @@ Checks whether the value in the specified column of the current row is null.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| columnIndex | number | Yes| Index of the specified column, starting from 0.|
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the value is null; returns **false** otherwise.|
**Example**
```js
const isColumnNull = resultSet.isColumnNull(resultSet.getColumnIndex("CODES"))
const isColumnNull = resultSet.isColumnNull(resultSet.getColumnIndex("CODES"));
```
### close
close(): void
......@@ -393,12 +413,13 @@ Closes this result set.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Example**
```js
let predicatesClose = new dataRdb.RdbPredicates("EMPLOYEE")
let promiseClose = rdbStore.query(predicatesClose, ["ID", "NAME", "AGE", "SALARY", "CODES"])
let predicatesClose = new dataRdb.RdbPredicates("EMPLOYEE");
let promiseClose = rdbStore.query(predicatesClose, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
promiseClose.then((resultSet) {
resultSet.close()
resultSet.close();
}).catch((err) => {
console.log('Failed to close resultset')
})
console.log('Failed to close resultset');
});
```
......@@ -41,7 +41,7 @@ Checks whether the application specified by **bundleName** is in the idle state.
| Name | Type | Mandatory | Description |
| ---------- | ---------------------------- | ---- | ---------------------------------------- |
| bundleName | string | Yes | Bundle name of an application. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the value of <b class="+ topic/ph hi-d/b " id="b597417553714">bundleName</b> is valid, <b class="+ topic/ph hi-d/b " id="b1897411555719">null</b> will be returned.|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. Returns the idle state of the application if the specified **bundleName** is valid; returns **null** otherwise.|
**Example**
......@@ -73,7 +73,7 @@ Checks whether the application specified by **bundleName** is in the idle state.
| Type | Description |
| ---------------------- | ---------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the value of **bundleName** is valid, **null** will be returned.|
| Promise&lt;boolean&gt; | Promise used to return the result. Returns the idle state of the application if the specified **bundleName** is valid; returns **null** otherwise.|
**Example**
......@@ -275,7 +275,7 @@ Queries the application usage duration statistics in the specified time frame at
| Type | Description |
| ---------------------------------------- | ---------------------------------------- |
| Promise&lt;Array&lt;[BundleStateInfo](#bundlestateinfo)&gt;&gt; | Promise used to return the result.|
| Promise&lt;Array&lt;[BundleStateInfo](#bundlestateinfo)&gt;&gt; | Promise used to return the result. |
**Example**
......@@ -309,7 +309,7 @@ Queries events of all applications based on the specified start time and end tim
| -------- | ---------------------------------------- | ---- | --------------------------------------- |
| begin | number | Yes | Start time. |
| end | number | Yes | End time. |
| callback | AsyncCallback&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -350,7 +350,7 @@ Queries events of all applications based on the specified start time and end tim
| Type | Description |
| ---------------------------------------- | -------------------------------------- |
| Promise&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Promise used to return the result.|
| Promise&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Promise used to return the result. |
**Example**
......@@ -380,7 +380,7 @@ Queries events of this application based on the specified start time and end tim
| -------- | ---------------------------------------- | ---- | --------------------------------------- |
| begin | number | Yes | Start time. |
| end | number | Yes | End time. |
| callback | AsyncCallback&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -417,7 +417,7 @@ Queries events of this application based on the specified start time and end tim
| Type | Description |
| ---------------------------------------- | -------------------------------------- |
| Promise&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Promise used to return the result.|
| Promise&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Promise used to return the result. |
**Example**
......@@ -455,7 +455,7 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses a
| Type | Description |
| ---------------------------------------- | ---------------------------------- |
| Promise&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Promise used to return the result.|
| Promise&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Promise used to return the result. |
**Example**
......@@ -486,7 +486,7 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses a
getRecentlyUsedModules(callback: AsyncCallback&lt;Array&lt;BundleActiveModuleInfo&gt;&gt;): void
This API uses an asynchronous callback to return at most 1000 records sorted by time (most recent first).
Obtains FA usage records. This API uses an asynchronous callback to return a maximum of 1000 FA usage records sorted by time in descending order.
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
......@@ -498,7 +498,7 @@ This API uses an asynchronous callback to return at most 1000 records sorted by
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -532,8 +532,8 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses an
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----------------------------------- |
| maxNum | number | Yes | Maximum number of returned records. The maximum and default value is **1000**.|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Yes | Callback used to return the result.|
| maxNum | number | Yes | Maximum number of returned records. The maximum value is **1000**.|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -578,14 +578,14 @@ Queries the priority group of the application specified by **bundleName**. If **
**Example**
```javascript
// Promise with bundleName
// Promise mode when bundleName is specified
let bundleName = "com.ohos.camera";
bundleState.queryAppUsagePriorityGroup(bundleName).then( res => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res));
}).catch( err => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise failed. because: ' + err.code);
});
// Promise without bundleName
// Promise mode when bundleName is not specified
bundleState.queryAppUsagePriorityGroup().then( res => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res));
}).catch( err => {
......@@ -597,7 +597,7 @@ bundleState.queryAppUsagePriorityGroup().then( res => {
queryAppUsagePriorityGroup(callback: AsyncCallback&lt;number&gt;): void
Queries the priority group of the current application . This API uses an asynchronous callback to return the result.
Queries the priority group of this application. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
......@@ -678,7 +678,7 @@ Sets the group for the application specified by **bundleName**. This API uses a
| Type | Description |
| ------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Promise&lt;void&gt; | Promise used to return the result. |
**Example**
......@@ -711,7 +711,7 @@ Sets the group for the application specified by **bundleName**. This API uses an
| ---------- | ------------------- | ---- | ------------------------- |
| bundleName | string | Yes | Bundle name of an application. |
| newGroup | [GroupType](#grouptype) | Yes | Application group. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -750,7 +750,7 @@ Registers a callback for application group changes. When an application group of
| Type | Description |
| ------------- | ----------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Promise&lt;void&gt; | Promise used to return the result. |
**Example**
......@@ -827,7 +827,7 @@ Deregisters the callback for application group changes. This API uses a promise
| Type | Description |
| ------------- | ------------------------ |
| Promise&lt;void&gt; | Promise used to return the result.|
| Promise&lt;void&gt; | Promise used to return the result. |
**Example**
......@@ -892,7 +892,7 @@ Queries statistics about system events (hibernation, wakeup, unlocking, and scre
| Type | Description |
| ---------------------------------------- | ---------------------------------------- |
| Promise&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Promise used to return the result.|
| Promise&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Promise used to return the result. |
**Example**
......@@ -923,7 +923,7 @@ Queries statistics about system events (hibernation, wakeup, unlocking, and scre
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| begin | number | Yes | Start time. |
| end | number | Yes | End time. |
| callback | AsyncCallback&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -961,7 +961,7 @@ Queries the number of notifications from all applications based on the specified
| Type | Description |
| ---------------------------------------- | ---------------------------------------- |
| Promise&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Promise used to return the result.|
| Promise&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Promise used to return the result. |
**Example**
......@@ -992,7 +992,7 @@ Queries the number of notifications from all applications based on the specified
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| begin | number | Yes | Start time. |
| end | number | Yes | End time. |
| callback | AsyncCallback&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -1012,6 +1012,8 @@ Provides the information about the FA usage.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory | Description |
| -------------------- | ---------------------------------------- | ---- | ----------------------------- |
| deviceId | string | No | ID of the device to which the FA belongs. |
......@@ -1033,6 +1035,8 @@ Provides the FA widget usage information.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory | Description |
| ---------------- | ------ | ---- | ----------- |
| formName | string | Yes | Widget name. |
......@@ -1047,6 +1051,8 @@ Provides the application group changes returned through a callback.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| ---------------- | ------ | ---- | ---------------- |
| appUsageOldGroup | number | Yes | Application group before the change.|
......@@ -1135,6 +1141,8 @@ Enumerates the application group types.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Default Value | Description |
| ------------------ | ---- | ----------------- |
| ACTIVE_GROUP_ALIVE | 10 | Group of active applications. |
......
......@@ -24,7 +24,7 @@ enterpriseDeviceManager.getDeviceSettingsManager((error, mgr) => {
## DeviceSettingsManager.setDateTime
setDateTime(admin: Want, time: number, callback: AsyncCallback<void>): void
setDateTime(admin: Want, time: number, callback: AsyncCallback\<void>): void
Sets the system time. This API uses an asynchronous callback to return the result.
......@@ -38,7 +38,7 @@ Sets the system time. This API uses an asynchronous callback to return the resul
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.|
| time | number | Yes| Timestamp (ms).|
| callback | AsyncCallback<void> | Yes| Callback used to the result. If the system time is set successfully, **err** is **null**; otherwise, **err** is an error object.|
| callback | AsyncCallback\<void> | Yes| Callback used to the result. If the system time is set successfully, **err** is **null**; otherwise, **err** is an error object.|
**Example**
......@@ -64,7 +64,7 @@ enterpriseDeviceManager.getDeviceSettingsManager((error, mgr) => {
## DeviceSettingsManager.setDateTime
setDateTime(admin: Want, time: number): Promise<void>
setDateTime(admin: Want, time: number): Promise\<void>
Sets the system time. This API uses a promise to return the result.
......@@ -83,8 +83,7 @@ Sets the system time. This API uses a promise to return the result.
| Type | Description |
| ----- | ----------------------------------- |
| Promise<void> | Promise that returns no value.|
| Promise\<void> | Promise that returns no value.|
**Example**
......
......@@ -47,7 +47,7 @@ Obtains an **[InputMethodController](#inputmethodcontroller)** instance.
| Type | Description |
| ----------------------------------------------- | ------------------------ |
| [InputMethodController](#inputmethodcontroller) | Returns the current **InputMethodController** instance.|
| [InputMethodController](#inputmethodcontroller) | Current **InputMethodController** instance.|
**Example**
......@@ -67,7 +67,7 @@ Obtains an **[InputMethodSetting](#inputmethodsetting8)** instance.
| Type | Description |
| ----------------------------------------- | ---------------------------- |
| [InputMethodSetting](#inputmethodsetting8) | Returns the current **InputMethodSetting** instance.|
| [InputMethodSetting](#inputmethodsetting8) | Current **InputMethodSetting** instance.|
**Example**
......@@ -94,15 +94,15 @@ Switches to another input method. This API can be used only in the stage model.
**Example**
```js
inputMethod.switchInputMethod({packageName:"com.example.kikakeyboard", methodId:"com.example.kikakeyboard"} ,(err,result) => {
inputMethod.switchInputMethod({packageName:'com.example.kikakeyboard', methodId:'com.example.kikakeyboard'} ,(err,result) => {
if (err) {
console.error("switchInputMethod err: " + JSON.stringify(err));
console.error('switchInputMethod err: ' + JSON.stringify(err));
return;
}
if (result) {
console.info("Success to switchInputMethod.(callback)");
console.info('Success to switchInputMethod.(callback)');
} else {
console.error("Failed to switchInputMethod.(callback)");
console.error('Failed to switchInputMethod.(callback)');
}
});
```
......@@ -129,14 +129,14 @@ Switches to another input method. This API can be used only in the stage model.
```js
inputMethod.switchInputMethod({packageName:"com.example.kikakeyboard", methodId:"com.example.kikakeyboard"}).then((result) => {
inputMethod.switchInputMethod({packageName:'com.example.kikakeyboard', methodId:'com.example.kikakeyboard'}).then((result) => {
if (result) {
console.info("Success to switchInputMethod.(promise)");
console.info('Success to switchInputMethod.(promise)');
} else {
console.error("Failed to switchInputMethod.(promise)");
console.error('Failed to switchInputMethod.(promise)');
}
}).catch((err) => {
console.error("switchInputMethod promise err: " + err);
console.error('switchInputMethod promise err: ' + err);
})
```
## inputMethod.getCurrentInputMethod<sup>9+</sup>
......@@ -151,7 +151,7 @@ Obtains the current input method. This API synchronously returns the **Inputmeth
| Type | Description |
| -------------------------------------------- | ------------------------ |
| [InputmethodProperty](#inputmethodproperty8) | **InputmethodProperty** instance of the current input method. |
| [InputmethodProperty](#inputmethodproperty8) | **InputmethodProperty** instance of the current input method.|
**Example**
......@@ -183,13 +183,13 @@ Hides the keyboard. This API uses an asynchronous callback to return the result.
```js
InputMethodController.stopInput((error, result) => {
if (error) {
console.error("failed to stopInput because: " + JSON.stringify(error));
console.error('failed to stopInput because: ' + JSON.stringify(error));
return;
}
if (result) {
console.info("Success to stopInput.(callback)");
console.info('Success to stopInput.(callback)');
} else {
console.error("Failed to stopInput.(callback)");
console.error('Failed to stopInput.(callback)');
}
});
```
......@@ -214,12 +214,12 @@ Hides the keyboard. This API uses a promise to return the result. If any paramet
```js
InputMethodController.stopInput().then((result) => {
if (result) {
console.info("Success to stopInput.(promise)");
console.info('Success to stopInput.(promise)');
} else {
console.error("Failed to stopInput.(promise)");
console.error('Failed to stopInput.(promise)');
}
}).catch((err) => {
console.error("stopInput promise err: " + err);
console.error('stopInput promise err: ' + err);
})
```
......@@ -241,7 +241,7 @@ Shows this soft keyboard. This API uses an asynchronous callback to return the r
```js
InputMethodController.showSoftKeyboard((err) => {
if (err == undefined) {
if (err === undefined) {
console.info('showSoftKeyboard success');
} else {
console.error('showSoftKeyboard failed because : ' + JSON.stringify(err));
......@@ -292,7 +292,7 @@ Hides this soft keyboard. This API uses an asynchronous callback to return the r
```js
InputMethodController.hideSoftKeyboard((err) => {
if (err == undefined) {
if (err === undefined) {
console.info('hideSoftKeyboard success');
} else {
console.error('hideSoftKeyboard failed because : ' + JSON.stringify(err));
......@@ -342,19 +342,17 @@ Obtains a list of activated or deactivated input methods. This API uses an async
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------- | ---- | ----------------------------- |
| enable | boolean | Yes | Whether to return a list of activated input methods. The value **true** means to return a list of activated input methods, and **false** means to return a list of deactivated input methods. |
| callback | Array<[InputMethodProperty](#inputmethodproperty8)> | Yes | Callback used to return a list of activated or deactivated input methods. |
| callback | Array<[InputMethodProperty](#inputmethodproperty8)> | Yes | Callback used to return a list of activated or deactivated input methods.|
**Example**
```js
imeList: Array<inputMethod.InputMethodProperty> = null
InputMethodSetting.listInputMethod(true, (err,data) => {
if (err) {
console.error("listInputMethod failed because: " + JSON.stringify(err));
console.error('listInputMethod failed because: ' + JSON.stringify(err));
return;
}
console.log("listInputMethod success");
this.imeList = data;
console.log('listInputMethod success');
});
```
......@@ -376,17 +374,15 @@ Obtains a list of activated or deactivated input methods. This API uses a promis
| Type | Description |
| ------------------------------------------------------------ | ----------------------------- |
| Promise<Array<[InputMethodProperty](#inputmethodproperty8)>> | Promise used to return a list of activated or deactivated input methods. |
| Promise<Array<[InputMethodProperty](#inputmethodproperty8)>> | Promise used to return a list of activated or deactivated input methods.|
**Example**
```js
imeList: Array<inputMethod.InputMethodProperty> = null
InputMethodSetting.listInputMethod(true).then((data) => {
console.info("listInputMethod success");
this.imeList = data;
console.info('listInputMethod success');
}).catch((err) => {
console.error("listInputMethod promise err: " + err);
console.error('listInputMethod promise err: ' + err);
})
```
......@@ -407,14 +403,12 @@ Obtains a list of installed input methods. This API uses an asynchronous callbac
**Example**
```js
imeList: Array<inputMethod.InputMethodProperty> = null
InputMethodSetting.listInputMethod((err,data) => {
if (err) {
console.error("listInputMethod failed because: " + JSON.stringify(err));
console.error('listInputMethod failed because: ' + JSON.stringify(err));
return;
}
console.log("listInputMethod success");
this.imeList = data;
console.log('listInputMethod success');
});
```
......@@ -435,12 +429,10 @@ Obtains a list of installed input methods. This API uses a promise to return the
**Example**
```js
imeList: Array<inputMethod.InputMethodProperty> = null
InputMethodSetting.listInputMethod().then((data) => {
console.info("listInputMethod success");
this.imeList = data;
console.info('listInputMethod success');
}).catch((err) => {
console.error("listInputMethod promise err: " + err);
console.error('listInputMethod promise err: ' + err);
})
```
......@@ -463,20 +455,20 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono
```js
InputMethodSetting.displayOptionalInputMethod((err) => {
if (err) {
console.error("displayOptionalInputMethod failed because: " + JSON.stringify(err));
console.error('displayOptionalInputMethod failed because: ' + JSON.stringify(err));
return;
}
console.info("displayOptionalInputMethod success");
console.info('displayOptionalInputMethod success');
});
```
### displayOptionalInputMethod
displayOptionalInputMethod(): Promise&lt;void&gt;
displayOptionalInputMethod(): Promise&lt;void&gt;
Displays a dialog box for selecting an input method. This API uses a promise to return the result. If any parameter is passed in, an exception is thrown.
Displays a dialog box for selecting an input method. This API uses a promise to return the result. If any parameter is passed in, an exception is thrown.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Return value**
......@@ -488,8 +480,8 @@ Displays a dialog box for selecting an input method. This API uses a promise to
```js
InputMethodSetting.displayOptionalInputMethod().then(() => {
console.info("displayOptionalInputMethod success.(promise)");
console.info('displayOptionalInputMethod success.(promise)');
}).catch((err) => {
console.error("displayOptionalInputMethod promise err: " + err);
console.error('displayOptionalInputMethod promise err: ' + err);
})
```
......@@ -8,7 +8,7 @@ The **\<CheckboxGroup>** component is used to select or deselect all check boxes
## Child Components
None
Not supported
## APIs
......@@ -18,8 +18,6 @@ Creates a check box group so that you can select or deselect all check boxes in
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| group | string | No| Group name.|
......
......@@ -27,7 +27,7 @@ Obtains an image from the specified source for subsequent rendering and display.
| Name| Type | Mandatory| Description |
| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| src | string\| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](ts-types.md#resource) | Yes | Image source. Both local and online images are supported.<br>When using an image referenced using a relative path, for example, `Image("common/test.jpg")`, the **\<Image>** component cannot be called across bundles or modules. Therefore, you are advised to use `$r` to reference image resources that need to be used globally.<br>- The following image formats are supported: PNG, JPG, BMP, SVG, GIF.<br>\- Base64 strings are supported. \ The value format is `data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data]`, where `[base64 data]` is a Base64 string.<br/>\- The value can also be a path starting with `dataability://`, which is used to access the image path provided by a Data ability.|
| src | string\| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](ts-types.md#resource) | Yes | Image source. Both local and online images are supported.<br>When using an image referenced using a relative path, for example, `Image("common/test.jpg")`, the **\<Image>** component cannot be called across bundles or modules. Therefore, you are advised to use `$r` to reference image resources that need to be used globally.<br>- The following image formats are supported: PNG, JPG, BMP, SVG, GIF.<br>\- Base64 strings are supported. The value format is `data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data]`, where `[base64 data]` is a Base64 string.<br/>\- The value can also be a path starting with `dataability://`, which is used to access the image path provided by a Data ability. |
## Attributes
......
......@@ -9,7 +9,7 @@ The **\<Radio>** component allows users to select from a set of mutually exclusi
## Child Components
None
Not supported
## APIs
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册