I am working on android 4.4.2 building an application with a system overlay/floating window created by an accessibility service.

Edit:I want to be able to hide the status bar GLOBALLY (in any app) (made possible by the code below) however when the overlay is shown i stop receiving acessibilityEvents from the listener and the software/hardware back button
When the floating view is injected into windowmanager:

  1. AccessibilityEvent listener does not receive updates
  2. Soft/hardware back key does not register (home/recents does)

in order to hide the status bar both 'FLAG_FULLSCREEN | FLAG_NOT_TOUCH_MODAL' are needed to allow touching the rest of the screen and 'View.SYSTEM_UI_FLAG_FULLSCREEN' allows

Accessibility Service (on connected method) :

@Override
public void onServiceConnected() {
serviceInstance = this;
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);

FloatingView = new View(this);

WindowManager.LayoutParams params = new WindowManager.LayoutParams(
0, 0,
0, 0,
TYPE_PRIORITY_PHONE,
FLAG_FULLSCREEN | FLAG_NOT_TOUCH_MODAL, PixelFormat.OPAQUE);
params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
params.windowAnimations = android.R.style.Animation_Toast;
params.gravity = Gravity.BOTTOM | Gravity.RIGHT;

windowManager.addView(FloatingView, params);

int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
FloatingView.setSystemUiVisibility(uiOptions);

}

Accessibility Service (on connected method) :

@Override
public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
Log.i("","Just log me some rubbish");

}

My AccessibilitySetup.xml:

<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeAllMask"
android:accessibilityFeedbackType="feedbackAllMask"
android:notificationTimeout="0"
android:accessibilityFlags="flagDefault"
android:canRetrieveWindowContent="true"
android:description="@string/notification_description"
/>