Disable screen during call

回眸只為那壹抹淺笑 提交于 2019-12-11 11:44:45

问题


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?


回答1:


You can solve this by adding a Container around the outermost Container in the QML file, and setting its background to Color.Black. Then added an id to the formerly outermost Container and implement an 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's reading to emit a signal to enable or disable the screen:

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

void CallProgress::SetScreenEnabled(const bool enabled) {
    emit screenEnabled(enabled);
}

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.



来源:https://stackoverflow.com/questions/29545315/disable-screen-during-call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!