系统覆盖影响键控

时间:2013-07-29 18:23:26

标签: java android overlay keyguard

我似乎无法解决这个奇怪的键盘问题。

症状:

添加系统覆盖后,我的键盘保持空白。然而,我可以按下按钮(PIN锁和紧急呼叫等)甚至解锁我的手机(感谢上帝!)。

代码:

爪哇

    viewHUD = new CustomView(getApplicationContext());

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
            PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.RIGHT | Gravity.TOP;
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    wm.addView(viewHUD, params);

截图

1.Keyguard Open(通常看起来像什么)

Keyguard Open

2.Buggy keyguard即当我运行此覆盖应用程序并按下电源按钮两次(锁定以进行)

Buggy keyguard

3。应用程序屏幕(注意青色文本-- mA

App Screen

4。 Keyguard关闭/最小化

Keyguard close/minimized

1 个答案:

答案 0 :(得分:0)

由于没有人回答,而且我找到了解决方案,这就解决了问题:

    viewToAdd.setBackgroundColor(Color.TRANSPARENT);

    // make the required params object for the HUD viewToAdd
    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            PixelFormat.TRANSPARENT);
    params.gravity = Gravity.RIGHT | Gravity.TOP;
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);