- Home /
Android Sleep Mode Problem
Hey guys,
I am having a problem detecting when my android device enters or exits sleep mode when you press the power button. Does it send a message kind of like OnApplicationPause() or OnApplicationFocus() when it enters or exits sleep mode? The reason why I want to detect this is because when I have a touch keyboard opened in my game and I press the power button to put it to sleep, the game screen will become black but the keyboard will be shown when you wake the phone back up. Here is the process of it occuring:
Activate touch keyboard with TouchScreenKeyboard.Open()
Put android phone into sleep mode with the power button
Press the power button again to wake the phone back up.
What I want the game to do is to turn off the keyboard whenever the user enters or exits sleep mode so that the screen will no longer be black and actually show all of my UI elements. Any kind of help will be greatly appreciated.
[Edit] Wanted to add some new information to help clarify my problem. I am coding in C# only and I am also using NGUI with Multi-Platform ToolKit Suite on the game. I have tried searching everywhere and the only thing that I have found was that the function OnResume() is called but that is a java only function isn't it? Is there a C# version of it? I have tried OnApplicationPause() and OnApplicationFocus() but no luck. I have found out that the back button sends an Keycode.Escape for Input so what would keycode be when you press the power button?
[Edit2] Okay I sort of fixed my problem, was doing too much work on it lol. Apparently OnApplicationPause does work but instead of OnApplicationPause(bool pause) I had OnApplicationPause(bool paused). It sucks that one letter can ruin your whole project. So now in order to fix my whole problem I just need to know how do I send a message of some kind to force close the android touchscreen keyboard. Setting the active value to false doesn't help me and the done value is read-only so I can't just set it to done.