I'm working on a BB10 app that needs to disable the screen in the same way that holding it close to your face does during a call. I implemented a proximity sensor to detect when the screen should be disabled or enabled, but BB10's APIs don't seem to provide a way to turn the screen on or off.
What can I use to disable and re-enable the screen?
You can solve this by adding a
Container
around the outermostContainer
in the QML file, and setting itsbackground
toColor.Black
. Then added anid
to the formerly outermostContainer
and implement anonScreenEnabled(enabled)
function to show or hide it.In the .cpp file, use the proximity sensor's reading to emit a signal to enable or disable the screen:
Add the 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 UI whenever the proximity sensor's readings detect that the user is close to the screen.