Turn off the screen during a call

I am working on a BB10 application that should turn off the screen in the same way as holding it next to your face while talking. I set the proximity sensor in to determine when the screen should be turned off or on , but the BB10 APIs do not seem to allow the screen to be turned on or off.

What can I use to turn the screen off and on again?

+1
source share
1 answer

You can solve this by adding a Container around the outer Container in the QML file and setting its background to Color.Black . Then we added the id to the previously deleted Container and implemented the onScreenEnabled(enabled) function to show or hide it.

 Container { background: Color.Black Container { id: callContainer ... } } function onScreenEnabled(enabled) { callContainer.visible = enabled; } 

In the .cpp file, use the proximity sensor to emit a signal to turn the screen on or off:

 void CallProgress::checkReading() { bool isClose = proximitySensor->reading()->close(); this->SetScreenEnabled(!isClose); } void CallProgress::SetScreenEnabled(const bool enabled) { emit screenEnabled(enabled); } 

Add signal and function declarations to the .h file. In the .qml file, connect the emitted signal to the corresponding QML function.

This will hide the user interface when the proximity sensor detects that the user is close to the screen.

+1
source

All Articles