5

Im trying to understand the ways to override the home button functionality in Android. Im doing a LockScreen App and the HOME button is unlocking the device.

I have been researching the last 3 days for a way to do it, and all the solutions I have found are not 100% effective (mostly due to the nature of HOME).

I have implemented solutions for all the solutions below in these three days but Im still not satisfied.

Problem:

I want to be able to override the HOME button functionality the same way as the WidgetLocker app in the AppStore. WidgetLocker is not a home launcher and it still can override the HOME better than anyone.

Link to WidgetLocker App

Disclaimer

  • First of all, I know that this is a security measure in Android so that an App does not take full control of the device, and I agree with it.
  • The official way is to implement a home launcher and its my preferred of them all, unfortunately my boss is still not 100% convinced on the path I selected, until I exhaust all other possibilities.
  • It must be for 4.0+ version of android

Solutions

  • Implement as Home launcher, catch the HOME intent and take care of home button presses, this has the problem that the user must select the app as the default home launcher and may not understand why (another problem I know, but still)
  • Implement a Service with a SYSTEM_OVERLAY view that is launched every time the device is locked, being effectively on top of everything, unfortunately (or fortunately security wise) the home button presses are still being sent to the app below and the default home launcher is still called.
  • Implement an activity parallel to the one that implements the lock screen, that contains the HOME Intent that is activated/deactivated programatically on the my app options, effectively changing the main app to a homelauncher on demand, when this activity is called it launches the lockscreen activity.

Is there any other way to do this?

Thanks in advance.

Tiago Costa
  • 971
  • 8
  • 10

1 Answers1

0

Look in the following topic for a way to override the home button: Overriding the functionality of Home Button

Personally though I would suggest going for the option where you implement your own home screen. We use a similair setup where I work. The app we want people to use is set as the default option when the home button is pressed. That way we can control where people can go to a large degree. This options can only be reset by resetting the application defaults of the app. This makes it non-permanent in case a fix to the device is needed.

For the latter implementation just install with the following lines in your manifest

<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />

Now the next time you press the home button a pop-up will ask you what you want to do.

Community
  • 1
  • 1
DrkNess
  • 676
  • 5
  • 4