• <bdo id='vBNqm'></bdo><ul id='vBNqm'></ul>

    <small id='vBNqm'></small><noframes id='vBNqm'>

    <i id='vBNqm'><tr id='vBNqm'><dt id='vBNqm'><q id='vBNqm'><span id='vBNqm'><b id='vBNqm'><form id='vBNqm'><ins id='vBNqm'></ins><ul id='vBNqm'></ul><sub id='vBNqm'></sub></form><legend id='vBNqm'></legend><bdo id='vBNqm'><pre id='vBNqm'><center id='vBNqm'></center></pre></bdo></b><th id='vBNqm'></th></span></q></dt></tr></i><div id='vBNqm'><tfoot id='vBNqm'></tfoot><dl id='vBNqm'><fieldset id='vBNqm'></fieldset></dl></div>
        <legend id='vBNqm'><style id='vBNqm'><dir id='vBNqm'><q id='vBNqm'></q></dir></style></legend>
      1. <tfoot id='vBNqm'></tfoot>

      2. 在 Android 上,如何检测显示系统对话框(电源选项

        时间:2023-08-30
        <i id='8812D'><tr id='8812D'><dt id='8812D'><q id='8812D'><span id='8812D'><b id='8812D'><form id='8812D'><ins id='8812D'></ins><ul id='8812D'></ul><sub id='8812D'></sub></form><legend id='8812D'></legend><bdo id='8812D'><pre id='8812D'><center id='8812D'></center></pre></bdo></b><th id='8812D'></th></span></q></dt></tr></i><div id='8812D'><tfoot id='8812D'></tfoot><dl id='8812D'><fieldset id='8812D'></fieldset></dl></div>
        <tfoot id='8812D'></tfoot>

        <legend id='8812D'><style id='8812D'><dir id='8812D'><q id='8812D'></q></dir></style></legend>
          <bdo id='8812D'></bdo><ul id='8812D'></ul>

              <small id='8812D'></small><noframes id='8812D'>

                  <tbody id='8812D'></tbody>
                • 本文介绍了在 Android 上,如何检测显示系统对话框(电源选项、最近的应用程序、低电量...)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想捕捉任何导致我的活动显示甚至部分隐藏的东西,例如电源选项、最近的应用程序托盘、低电量通知等...我很难检测到这些系统事件.

                  I'd like to catch anything that causes the display of my Activity to get even partially hidden, e.g. power options, recent apps tray, low battery notification, etc... and I'm having a hard time to detect these system events.

                  我很确定当此类事件发生时会调用 onPause(),但它似乎是错误的......还是我?

                  I was pretty sure onPause() would be called when such events happen, but it seems to be wrong... or is it me?

                  还有其他想法吗?...我最好不要单独挂钩每个系统广播操作,因为我希望尽可能通用(并对隐藏我的 Activity 的任何事情做出反应).

                  Any other idea?... I'd preferably not hook on each system broadcast action individually, since I'd like to be as generic as possible (and react to ANYTHING that hides my Activity).

                  推荐答案

                  在开发一个 kiosk 风格的应用程序时,我知道一些 Dialogs 会出现在前台并且可以被检测到

                  On working on a kiosk style app I know that some Dialogs come to the foreground and can be detected by

                      ActivityManager activityManager = (ActivityManager)getBaseContext()
                         .getSystemService(Activity.ACTIVITY_SERVICE);
                      String className = activityManager.getRunningTasks(1).get(0).topActivity.getClassName();
                  

                  一个例子是蓝牙绑定对话框,它将 com.android.settings 带到前台.

                  An example for that is the bluetooth-binding dialog that brings the com.android.settings to the foreground.

                  一个反例是没有出现在前台的电源按钮对话框(关闭、重启等).

                  A counter-example is the power-button dialog (Turn off, Reboot etc) that does not come to the foreground.

                  请注意,您可以使用此广播关闭系统对话框(甚至是电源按钮对话框):

                  Note that you can close system dialogs (even the power-button dialog) with this broadcast:

                      Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
                          sendBroadcast(closeDialog);
                  

                  但在大多数(所有较新的?)设备上,此广播甚至会关闭软件键盘,因此不建议运行频繁发送它的服务,因为用户将无法在文本字段中输入任何内容.

                  But on most (all newer?) devices this Broadcast will even close the software keyboard, so it is not advisable to have a service running that frequently sends it as the user will then be unable to enter anything into a text field.

                  请注意,此类行为肯定会使您的应用程序成为恶意软件,使其无法在 google play 上发布.

                  Note that such behaviour will definetly gratify your app a status as beeing malware, keeping it from beeing published on google play.

                  这篇关于在 Android 上,如何检测显示系统对话框(电源选项、最近的应用程序、低电量...)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:覆盖对话框 onBackPressed()? 下一篇:Android:如何从警报对话框启动 Activity

                  相关文章

                  最新文章

                  1. <legend id='12i70'><style id='12i70'><dir id='12i70'><q id='12i70'></q></dir></style></legend>

                    <small id='12i70'></small><noframes id='12i70'>

                        <bdo id='12i70'></bdo><ul id='12i70'></ul>
                    1. <i id='12i70'><tr id='12i70'><dt id='12i70'><q id='12i70'><span id='12i70'><b id='12i70'><form id='12i70'><ins id='12i70'></ins><ul id='12i70'></ul><sub id='12i70'></sub></form><legend id='12i70'></legend><bdo id='12i70'><pre id='12i70'><center id='12i70'></center></pre></bdo></b><th id='12i70'></th></span></q></dt></tr></i><div id='12i70'><tfoot id='12i70'></tfoot><dl id='12i70'><fieldset id='12i70'></fieldset></dl></div>
                    2. <tfoot id='12i70'></tfoot>