安卓系统工具:显示系统级警报:如何使用这个权限?

编程入门 行业动态 更新时间:2024-10-19 04:26:31
本文介绍了安卓系统工具:显示系统级警报:如何使用这个权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

对所用的谷歌Play商店称为画面过滤器,其目的是覆盖一些半透明的黑色整个屏幕的应用程序,以允许在屏幕为比最小亮度调光

为此,它使用了一个名为显示系统级警报。

许可
  • 在哪里,让我做这件事在我的应用程序的文档?

  • 可这系统级警报拦截触摸事件?这是这样我就可以让我的应用程序接管an安卓是应该留在我们的建设。

  • 我喜欢这种方法,因为它$ P $被关闭之前,它被打开了(这将触发报警),当然,除非有涉及锤子pvents电话。

    解决方案
  • 文档的 Manifest.Permission 显示,SYSTEM_ALERT_WINDOW是您正在寻找的权限。您将宣布在清单此权限,然后在对话框或任何其他类型的的窗口您将设置该标志 WindowManager.LayoutParams.TYPE_SYSTEM_ALERT 。因此,对于一个对话框它是这样的:

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

  • 是的,这将是能够拦截触摸事件。系统警报,就像一个低电量警告,总是在所有其他应用程序顶开,所以无论窗口你弹出将重点等。基于你想做什么这一点,我想你可以这样做:弹出对话框(作为一个系统级警报),它需要密码才能使它走了。

  • 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 than the minimum brightness.

    It does this using a permission called "Display System-Level Alerts".

  • Where is the documentation that allows me to do this in my app?

  • Can this "system-level alert" intercept touch events? This is so I can get my app to take over an Android that is supposed to stay in our building.

  • I like this approach because it prevents the phone from being turned off before it is turned over (which would trigger an alarm), unless of course there is a hammer involved.

    解决方案

  • 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);

  • 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.

  • 更多推荐

    安卓系统工具:显示系统级警报:如何使用这个权限?

    本文发布于:2023-11-27 08:02:45,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1637195.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:系统   警报   使用这个   权限   工具

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!