Search code examples
androidcustom-actionpower-management

How do I run an app using the power button


I have been around browsing tutorials for android power button mods, I have a couple of questions in this regard Those being:

  1. How do I set a specific timer to make my app run after the button as been depressed for say 5 seconds.
  2. How do I make my app run at start up.

The basic premise of it being a personal security app(So you are not thinking I am doing anything stupid with it.). I am trying to give it easy access as well as quick functionality.

Any tips would be wonderful.
-Thanks.


Solution

  • How do I set a specific timer to make my app run after the button as been depressed for say 5 seconds.

    This is not supported.

    How do I make my app run at start up.

    If your "app" has a UI that is supposed to "run at start up", make it be the home screen.

    If, instead, you are trying to do something else (e.g., schedule AlarmManager events), register a BroadcastReceiver for the BOOT_COMPLETED action in the manifest, and have the RECEIVE_BOOT_COMPLETED permission.