1# Interface (FlashQuery) 2<!--Kit: Camera Kit--> 3<!--Subsystem: Multimedia--> 4<!--Owner: @qano--> 5<!--SE: @leo_ysl--> 6<!--TSE: @xchaosioda--> 7 8> **NOTE** 9> 10> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. 11> - This interface was first introduced in API version 12. In this version, a compatibility change was made that preserved the initial version information of inner elements. As a result, you might see outer element's @since version number being higher than that of the inner elements. However, this discrepancy does not affect the functionality of the interface. 12 13FlashQuery provides APIs to query the flash status and mode of a camera device. 14 15## Modules to Import 16 17```ts 18import { camera } from '@kit.CameraKit'; 19``` 20 21## hasFlash<sup>11+</sup> 22 23hasFlash(): boolean 24 25Checks whether the camera device has flash. This API uses an asynchronous callback to return the result. 26 27**Atomic service API**: This API can be used in atomic services since API version 19. 28 29**System capability**: SystemCapability.Multimedia.Camera.Core 30 31**Return value** 32 33| Type | Description | 34| ---------- | ----------------------------- | 35| boolean | Check result for whether the camera device has flash. **true** if it has flash, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 36 37**Error codes** 38 39For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 40 41| ID | Error Message | 42| --------------- | --------------- | 43| 7400103 | Session not config, only throw in session usage. | 44 45**Example** 46 47```ts 48import { BusinessError } from '@kit.BasicServicesKit'; 49 50function hasFlash(photoSession: camera.PhotoSession): boolean { 51 let status: boolean = false; 52 try { 53 status = photoSession.hasFlash(); 54 } catch (error) { 55 // If the operation fails, error.code is returned and processed. 56 let err = error as BusinessError; 57 console.error(`The hasFlash call failed. error code: ${err.code}`); 58 } 59 return status; 60} 61``` 62 63## isFlashModeSupported<sup>11+</sup> 64 65isFlashModeSupported(flashMode: FlashMode): boolean 66 67Checks whether a flash mode is supported. 68 69**Atomic service API**: This API can be used in atomic services since API version 19. 70 71**System capability**: SystemCapability.Multimedia.Camera.Core 72 73**Parameters** 74 75| Name | Type | Mandatory| Description | 76| --------- | ----------------------- | ---- | --------------------------------- | 77| flashMode | [FlashMode](arkts-apis-camera-e.md#flashmode) | Yes | Flash mode. If the input parameter is null or undefined, it is treated as 0 and the flash is turned off. | 78 79**Return value** 80 81| Type | Description | 82| ---------- | ----------------------------- | 83| boolean | Check result for the support of the flash mode. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](arkts-apis-camera-e.md#cameraerrorcode) is returned.| 84 85**Error codes** 86 87For details about the error codes, see [Camera Error Codes](errorcode-camera.md). 88 89| ID | Error Message | 90| --------------- | --------------- | 91| 7400103 | Session not config, only throw in session usage. | 92 93**Example** 94 95```ts 96import { BusinessError } from '@kit.BasicServicesKit'; 97 98function isFlashModeSupported(photoSession: camera.PhotoSession): boolean { 99 let status: boolean = false; 100 try { 101 status = photoSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO); 102 } catch (error) { 103 // If the operation fails, error.code is returned and processed. 104 let err = error as BusinessError; 105 console.error(`The isFlashModeSupported call failed. error code: ${err.code}`); 106 } 107 return status; 108} 109``` 110