tencent cloud

All product documents
Tencent Cloud Super App as a Service
Last updated: 2025-02-24 17:10:36
Screen
Last updated: 2025-02-24 17:10:36

setVisualEffectOnCapture

Notes:
This API is supported in mini programs but not in mini games.
This API is called using wx.setVisualEffectOnCapture(Object object).
Feature description:Sets the screen display when taking screenshots or recording the screen.(for Android only).
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
visualEffect
string
none
False
The visual effect during screenshot/recording. Supports none or hidden. Passing hidden will hide the screen during capture.
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure).

setScreenBrightness

This API is called using wx.setScreenBrightness(Object object).
Feature description:Sets the screen brightness.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
value
number
-
True
Screen brightness value, ranging from 0 (darkest) to 1 (brightest). On Android, supports a special value of -1, which means the screen brightness follows the system setting.
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure).

setKeepScreenOn

This API is called using wx.setKeepScreenOn(Object object).
Feature description:Sets whether to keep the screen on. This setting only takes effect within the current mini program and will be invalid once you leave the mini program.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
keepScreenOn
boolean
-
True
Whether to keep the screen on.
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure).
Example:
wx.setKeepScreenOn({
keepScreenOn: true
})

onUserCaptureScreen

This API is called using wx.onUserCaptureScreen(function listener).
Notes:
This API is supported in mini programs but not in mini games.
Feature description:Listens for user-initiated screenshot event. It is triggered when the user takes a screenshot using the system screenshot button. Only one listener can be registered.
Parameter and description:function listener. The listener for user-initiated screenshot event.
Example:
wx.onUserCaptureScreen(function (res) {
console.log('User took a screenshot')
})

onScreenRecordingStateChanged

Notes:
This API is supported in mini programs but not in mini games.
This API is called using wx.onScreenRecordingStateChanged(function listener).
Feature description:Listens for user-initiated screen recording event.
Parameter and description:function listener. The listener for user-initiated screen recording event.
Property
Type
Description
state
string
Screen recording status. Valid values:
start: Screen recording started
stop: Screen recording stopped
Example:
// Listen for user-initiated screen recording event
const handler = function (res) {
console.log(res.state)
}
wx.onScreenRecordingStateChanged(handler)

// Cancel listening for user screen recording event
wx.offScreenRecordingStateChanged(handler)

offUserCaptureScreen

This API is called using wx.offUserCaptureScreen(function callback).
Notes:
This API is supported in mini programs but not in mini games.
Feature description: Cancels the listener for user-initiated screenshot event.
Parameter and description:function callback. The callback function for user-initiated screenshot event.

offScreenRecordingStateChanged

Notes:
This API is supported in mini programs but not in mini games.
This API is called using wx.offScreenRecordingStateChanged(function listener).
Feature description:Removes the listener for user-initiated screen recording event.
Parameter and description:function listener. The listener passed to onScreenRecordingStateChanged. If not provided, all listeners will be removed.
Example:
// Listen for user-initiated screen recording event
const handler = function (res) {
console.log(res.state)
}
wx.onScreenRecordingStateChanged(handler)

// Cancel listening for user screen recording event
wx.offScreenRecordingStateChanged(handler)
const listener = function (res) { console.log(res) }

wx.onScreenRecordingStateChanged(listener)
wx.offScreenRecordingStateChanged(listener) // Must pass the same function object used in onScreenRecordingStateChanged

getScreenRecordingState

Notes:
This API is supported in mini programs but not in mini games.
This API is called using wx.getScreenRecordingState(Object object).
Feature description:Queries whether the user is currently recording the screen.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure).
object.success callback function parameter:Object res.
Property
Type
Description
state
string
Screen recording status. Valid values:
on: Enabled
off: Disabled
Example:
wx.getScreenRecordingState({
success: function (res) {
console.log(res.state)
},
})

getScreenBrightness

This API is called using wx.getScreenBrightness(Object object).
Notes:
If the automatic brightness adjustment feature is enabled in the Android system settings, the screen brightness will automatically adjust according to the light. This API can only obtain the value before the automatic brightness adjustment, not the real-time brightness value.
Feature description:Gets the screen brightness.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure).
object.success callback function parameter:Object object.
Property
Type
Description
value
number
Screen brightness value, ranging from 0 (darkest) to 1 (brightest).



Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support