View Single Post
jflatt's Avatar
Posts: 534 | Thanked: 723 times | Joined on Oct 2009
#107
I'm not getting auto switchover either, but here is how you can use the ALS, it seems to work on startup (note, forum mangled, the QML should be all one line, and the OR statement looks wrapped):
Code:
function isNight() {
    var als;
    als = Qt.createQmlObject('import QtMobility.sensors 1.2; AmbientLightSensor { }', this, null);
    als.start();
    if (als.reading.lightLevel == 1 || als.reading.lightLevel == 2) {
        als.destroy(1000);
        return true;
    }
    als.destroy(1000);
    return false;
}
 

The Following 4 Users Say Thank You to jflatt For This Useful Post: