0

I would like to intercept and cancel(in some circumstances) the Home Button and Stack Button press on Android 4.1 API Level 16.

Actual limitations: - I can't change OS version, it must absolutely be Android 4.1. - Buttons are virtual, not physical - Can't be rooted

I found an exemple on the web but i can intercept all buttons except home and stack.

I tried to convert this code to MonoDroid, but i can't find the TYPE_GUARD parameter.

public override void OnAttachedToWindow()
{
  this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
  super.onAttachedToWindow();
}

I also override the OnKeyDown and DispatchKeyEvent, and again i can catch all button press except home and stack.

Thanks in advance!

SlashJ
  • 687
  • 1
  • 11
  • 31

2 Answers2

0

I would direct you to this question: Detect Home Button Press in Android

Which explains why you can not do this (especially after 4.0 I believe).

I would tend a guess that the "Stack" button would be the same, these are designed to be os specific and override anything the application may try to do.

You can detect some life cycle events and try to use those if you just need to know but you can not prevent or change what happens.

Community
  • 1
  • 1
Zach S.
  • 130
  • 1
  • 9
-1

This guy got it running... different way, but running... he's using a BroadcastReceiver for ActionCloseSystemDialogs.

Detect home button press in android

Community
  • 1
  • 1