Sorry for this basic questions, but I am not sure how to enabling/disabling LocationEvents in a running application.
I have an app which enabled LocationEvents based on a parameter in properties.xml.
function onStart(state) {
if (Application.Properties.getValue("gpsmode_prop") == true ) {
Position.enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:onPosition));
}
}
function onStop(state) {
if (Application.Properties.getValue("gpsmode_prop") == true ) {
Position.enableLocationEvents(Position.LOCATION_DISABLE, method(:onPosition));
}
}While starting up the App with gpsmode_prop == true||false everything works well and GPS is either on or off. However, if I want to switch it off or on, while the App is running, I would need to call Position.enableLocationEvents(Position.LOCATION_DISABLE, method(:onPosition) or Position.enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:onPosition)); from the MenuDelegate.
if (gpsmode == true ) {
Application.Properties.setValue("gpsmode_prop", false );
Position.enableLocationEvents(Position.LOCATION_DISABLE, null);
} else {
pplication.Properties.setValue("gpsmode_prop", true );
//Position.enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:onPosition));
}
Disabling works as well, as I can set method to null, but I am actually not sure how to link back to the Application.AppBase to call the onPostion method.
