Shweta Shweta - 5 months ago 112
Android Question

How to dismiss system dialog in Android?

I have to dismiss this system

Dialog
(Attached below).
I am getting this value but I am not able to dismiss it programmatically in Service not in Activity.

My question is:



  1. Is it possible to dismiss it ? if yes please help or guide me how to achieve it.




enter image description here

Answer

Please check it

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

        if (! hasFocus) {
            Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
            sendBroadcast(closeDialog);
        }
    }

It is working in my code.

Comments