Android: System Tools: Display System Level Alerts: How to use this Permission?

后端 未结 1 1209
-上瘾入骨i
-上瘾入骨i 2021-02-02 04:27

There is an app on the Google \"Play Store\" called \"Screen Filter\", which is designed to cover the entire screen with some translucent black, to allow the screen to be dimmer

1条回答
  •  独厮守ぢ
    2021-02-02 04:30

    1. Docs for Manifest.Permission show that the SYSTEM_ALERT_WINDOW is the permission you are looking for. You would declare this permission in the Manifest and then in a Dialog or any other kind of Window you would set this flag WindowManager.LayoutParams.TYPE_SYSTEM_ALERT. So for a Dialog it would look like this:

      dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);

    2. Yes, it will be able to intercept touch events. System alerts, like a low battery warning, always open on top of all other applications, so whatever Window you pop up will take focus, etc. Based on what you want to do with this, I'd imagine you could do something like: pop up a Dialog (as a system level alert) which needs a password to make it go away.

    0 讨论(0)
提交回复
热议问题