Search code examples
androidandroid-homebutton

Disable GotoHome behaviour provided by a mouse middle button click on Android


In a business context (not commercial app), I need to avoid middle button click behaviour, that is to say displaying Home Screen

I spent hours browsing Stackoverflow pages, and the conclusion is often :

  • it's not possible, regarding obvious security considerations

My need is a bit different :

  • I use a connected mouse, I don't want to override device hardware button.
  • my app will only be use in a business context, not publicly.

Details :

  • my device is a Samsung Galaxy 3 (Model Number GT-P5210, Android version 4.2.2)
  • the mouse is a classical 3-buttons mouse (left-click, mouse wheel, right-click)

I can accept :

I can't accept :

-- Thanks, Jerome.

Excuse my awful english, I'm french !


Solution

  • Putting this 3 lines to the manifest solved the problem. Firstly it didn't work because I made a mistake on activity name

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.HOME" />
        <category android:name="android.intent.category.DEFAULT" />
      </intent-filter>
    

    Thanks !

    --

    Jerome