Android的任务管理器或系统对话框 [英] Android task manager or system dialog

查看:266
本文介绍了Android的任务管理器或系统对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道有没有办法让事件而显示系统对话框(如任务管理器,关闭警报,...)。

我可以通过意向从我的活动中关闭系统对话框如下图所示。

 意图closeDialog =新的意图(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
        sendBroadcast(closeDialog);
 

但在我的code,我需要知道的是显示在屏幕上的系统对话框(可以是任务管理器/关机对话框......),这样我就可以调用上面的$ C $下关闭吧。

我搜索的意图过滤器没有发现。

解决方案

把下面的方法在你的Actvity并为您的最近的应用程序对话自动关闭

 公共无效onWindowFocusChanged(布尔hasFocus){
        super.onWindowFocusChanged(hasFocus);

        Log.e(焦点访谈调试,聚焦变了​​!);

        如果(!hasFocus){
            Log.e(焦点访谈调试,失落的焦点!);

            意图closeDialog =新的意图(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
            sendBroadcast(closeDialog);
        }
    }
 

注意:它仅适用于单个活动。不适合你的应用程序的所有活动。

I would like to know is there a way to get events while displaying a System dialog (Such task manager, shut down alert,...).

I can close the system dialogs from my activity through intent like below

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

But in my code I need to know a system dialog is shown over the screen (They can be Task manager/ Shut down dialog ...), so that I can invoke the above code for closing it.

I searched for intent filters nothing found.

解决方案

put below method in your Actvity and check recent app dialog close automatically.

public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);

        Log.e("Focus debug", "Focus changed !");

        if (!hasFocus) {
            Log.e("Focus debug", "Lost focus !");

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

Note: it only work for single Activity. not for all activity in your app.

这篇关于Android的任务管理器或系统对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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