安卓系统工具:显示系统级警报:如何使用这个权限? [英] Android: System Tools: Display System Level Alerts: How to use this Permission?

查看:1858
本文介绍了安卓系统工具:显示系统级警报:如何使用这个权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

  2. 可这系统级警报拦截触摸事件?这是这样我就可以让我的应用程序接管<一href="http://stackoverflow.com/questions/9590851/does-android-support-lock-down-to-a-fully-replaced-interface/9591107#comment12164786_9591107">an安卓是应该留在我们的建设。

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

解决方案
  1. 文档的 Manifest.Permission 显示,<一个href="http://developer.android.com/reference/android/Manifest.permission.html#SYSTEM_ALERT_WINDOW"><$c$c>SYSTEM_ALERT_WINDOW是您正在寻找的权限。您将宣布在清单此权限,然后在对话框或任何其他类型的的窗口您将设置该标志 WindowManager.LayoutParams.TYPE_SYSTEM_ALERT 。因此,对于一个对话框它是这样的:

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

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

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

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

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

解决方案

  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.

这篇关于安卓系统工具:显示系统级警报:如何使用这个权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆