0

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.

MobDev
  • 1,489
  • 1
  • 17
  • 26

2 Answers2

0

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.

Dhaval Parmar
  • 18,812
  • 8
  • 82
  • 177
  • Thanks Dhaval, But I am facing problem with it. I am opening a browser session from my activity, Then the above method does not invoked because the current focused window is browser. – MobDev Apr 12 '13 at 06:45
  • @anish: yes this heppend. but instead of open browser create new activity inside that put web view and open that link inside that activity in your app. its work. – Dhaval Parmar Apr 12 '13 at 06:48
  • Yes that is an alternative, but my project requirements doesn't allow to do like that. So its not possible to detect when a system dialog is shown am I right? – MobDev Apr 12 '13 at 07:19
  • @anish: yes it is not possible. – Dhaval Parmar Apr 12 '13 at 07:21
  • So I am going for a back ground thread for sending close dialog broad cast repeatedly. I think that will work for me. Thank You Dhaval – MobDev Apr 12 '13 at 07:46
  • How can i dismiss the runtime permission dialog?? – Vinoj Vetha Jan 17 '19 at 07:53
0

Use Broadcast-Receiver and place intent inside onreceive() method.Then register this receiver where you display your alert dialog. Then it automatically disable settings,recent apps button ----Nagesh

Nagesh
  • 1
  • 1