Sorry... didn't finish...
I know you can keep the display on with:
NativeApplication.nativeApplication.systemIdleMode = KEEP_AWAKE;
But I'd like to turn the display off and then back on when the event happens.
I dont think the app runs in the background if the phone goes to sleep.
I have an app that sounds an alarm. If the user switches the screen off the alarm wont sound. Unless the phone is plugged in and set to stay awake in the android settings. Then they can switch the screen off and the alarm will sound (and turn the screen on).
At the moment I dont think its possible. I read somewhere that there will be a way using native commands, but not yet.
You may be right but it appears it's still running. I'm actually using sockets to connect to a server app. When I send data to the mobile device to display something, when I turn the Android on, the data is showing. I can then send something to the server and it receives it ok. I also monitor the connection state on the server and it's not disconnected when it goes to sleep.
I would be happy to just be able to turn the display on and off and keep the application awake if there's a way to do that.