1# @system.battery (Battery Information) 2 3<!--Kit: Basic Services Kit--> 4<!--Subsystem: PowerManager--> 5<!--Owner: @zhang-yinglie; @volcano_wang--> 6<!--Designer: @wangyantian0--> 7<!--Tester: @alien0208--> 8<!--Adviser: @w_Machine_cc--> 9 10The **battery** module allows you to query the charging status and remaining power of a device. 11 12> **NOTE** 13> - The APIs of this module are no longer maintained since API version 6. It is recommended that you use [`@ohos.batteryInfo`](js-apis-battery-info.md). 14> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. 15 16 17## Modules to Import 18 19 20```js 21import {Battery, BatteryResponse } from '@kit.BasicServicesKit'; 22``` 23 24 25## Battery.getStatus<sup>(deprecated)</sup> 26 27getStatus(options?: GetStatusOptions): void; 28 29Obtains the current charging state and battery level. 30 31**System capability**: SystemCapability.PowerManager.BatteryManager.Lite 32 33**Parameters** 34 35| Name| Type| Mandatory| Description| 36| -------- | -------- | -------- | -------- | 37| options | [GetStatusOptions](#getstatusoptionsdeprecated) | No| Object that contains the API calling result. This parameter is optional and is left blank by default.| 38 39**Example** 40 41```js 42Battery.getStatus({ 43 success: (data: BatteryResponse) => { 44 console.log('success get battery level:' + data.level); 45 }, 46 fail: (data: string, code: number) => { 47 console.error('fail to get battery level code:' + code + ', data: ' + data); 48 } 49}); 50``` 51 52## GetStatusOptions<sup>(deprecated)</sup> 53 54Object that contains the API calling result. 55 56**System capability**: SystemCapability.PowerManager.BatteryManager.Lite 57 58| Name | Type | Mandatory| Description | 59| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | 60| success | (data: [BatteryResponse](#batteryresponsedeprecated)) => void | No | Called when an API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponsedeprecated) type.| 61| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. | 62| complete | () => void | No | Called when an API call is complete. | 63 64## BatteryResponse<sup>(deprecated)</sup> 65 66Defines a response that returns the charging status and remaining power of the device. 67 68**System capability**: SystemCapability.PowerManager.BatteryManager.Lite 69 70| Name| Type| Readable| Writable| Description| 71| -------- | -------- | -------- | -------- | -------- | 72| charging | boolean | Yes| No| Whether the battery is being charged. The value **true** indicates that the battery is being changed; **false** indicates the opposite. The default value is **false**.| 73| level | number | Yes| No| Current battery level, which ranges from **0.00** to **1.00**.| 74