Android floating window with hidden statusbar Accessibility problems

强颜欢笑 提交于 2019-12-06 09:33:09

After long hours and a week of research i found theres is no way to do both of these due to security restrictions. i will implmenet these features in the root mode of my app.

the workaround i am using is a simple button that revives the system ui and removes the view that is blocking the accessibility input

Hey i think this would work!!!!

You just need to set WindowManager.LayoutParams height width property correctly. By this you can able to receiving acessibilityEvents from the listener and the software/hardware back button.

Try this

WindowManager manager = ((WindowManager) context.getApplicationContext()
            .getSystemService(Context.WINDOW_SERVICE));
    WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
    localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
    localLayoutParams.gravity = Gravity.TOP;
    localLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
            // this is to enable the notification to receive touch events
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
            // Draws over status bar
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
    localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    localLayoutParams.height = retrieveStatusBarHeight(context);
    localLayoutParams.format = PixelFormat.TRANSPARENT;
    StatusBarOverlayView view = new StatusBarOverlayView(context);
    manager.addView(view, localLayoutParams);

public static int retrieveStatusBarHeight(Context context) {
    int result = 0;
    int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        result = context.getResources().getDimensionPixelSize(resourceId);
    }
    return result;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!