6

I want to get an android device to wake up from sleep or however the state in which the phone gets after a certain amount of inactivity when the screen goes dark, by detecting a touch to the screen instead of clicking on any button.

In the documentation the only thing I have found is the FLAG_TOUCHABLE_WHEN_WAKING flag in WindowManager.LayoutParams and it says:

Window flag: When set, if the device is asleep when the touch screen is pressed, you will receive this first touch event. Usually the first touch event is consumed by the system since the user can not see what they are pressing on.

I thought that meant that if the device's screen is turned off and that flag is set for an Activity then it will wake up to the touch (which is what I want it to do). Am I misunderstanding the purpose of this flag? Are there additional implementation details I'm ignoring? Is there some other way?

bluediapente
  • 3,946
  • 5
  • 32
  • 38
  • Based on FLAG_TOUCHABLE_WHEN_WAKING description you quoted, it sounds very likely system is catching this event, never sending it further to your Activity. Personally I wouldn't rely on it's working as you're expecting but this is something I've never dealt with. – harism May 06 '11 at 18:56

1 Answers1

4

Am I misunderstanding the purpose of this flag?

AFAIK, yes. There is a slice of time between when the screen turns off and when the device falls asleep. During this time, if the user touches the screen someplace where the window has this flag, the screen turns on again and the inactivity timer is reset.

I can find no other use of this flag in the Android source code.

Is there some other way?

No. If the device is asleep, touch screen events are not registered.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • still not possible?!! and what about if the device is rooted and I can make whatever I want to it in order to achieve that?!! – Muhammed Refaat Jul 25 '16 at 11:03
  • 1
    @MuhammedRefaat: What you want has little to do with *software* and a lot to do with *hardware*. Some devices have this capability already; devices that do not cannot add it purely via software AFAIK. – CommonsWare Jul 25 '16 at 11:12