Search code examples
androidandroid-intentandroid-serviceandroid-launcherandroid-homebutton

Launch service on home button press


Android M: I am trying create/resume a service whenever the home button is pressed. The activity that is displayed when the home button is pressed should not be destroyed/paused. I have tried to make my service filter the android.intent.category.HOME intent but android does not seem to recognize this as a launcher. Is there any workaround to solve this problem?


Solution

  • I am trying create/resume a service whenever the home button is pressed.

    Implement a home screen. Convince users to use your home screen. Tie your service into your home screen implementation.

    The activity that is displayed when the home button is pressed should not be destroyed/paused

    The activity that is displayed will be paused, because the HOME button always brings another activity to the foreground. The only exception is if the home screen is already in the foreground. There is nothing that you can do about this, other than write your own mobile OS.

    The activity that is displayed will be destroyed if and when Android decides to terminate the process associated with that activity. You do not get a vote.

    I have tried to make my service filter the android.intent.category.HOME intent but android does not seem to recognize this as a launcher.

    That is because the HOME button will start an activity, not a service.

    So there is no way of implementing your own launcher that does not open the Home screen?

    You are welcome to implement your own customized version of Android that offers this. Then, you can put that version of Android in your own custom ROM, then convince people to use that ROM.