0

I'm trying to write a android application by using the double click power button to control activity function.

Like this app Speaking Clock: TellMeTheTime (by: Andreas Meyer)

anyone can tell me how to write the java code.

529336
  • 1

1 Answers1

0

You can't really override the behavior of the power button see here for explanation

If you are dead set on using the power button you could try listening for both SCREEN_ON and SCREEN_OFF events and keeping a timestamp in SCREEN_ON. If SCREEN_OFF happens within some reasonable time after on did then you could trigger your thing to say the time out load.

Community
  • 1
  • 1
FoamyGuy
  • 46,603
  • 18
  • 125
  • 156