Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to dismiss system dialog in Android?

Tags:

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

like image 867
Ash Avatar asked Jun 03 '14 11:06

Ash


2 Answers

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.

like image 187
Ash Avatar answered Sep 25 '22 04:09

Ash


You can use - ACTION_CLOSE_SYSTEM_DIALOGS

Broadcast Action: This is broadcast when a user action should request a temporary system dialog to dismiss.

public static final String ACTION_CLOSE_SYSTEM_DIALOGS

Added in API level 1

Broadcast Action: This is broadcast when a user action should request a temporary system dialog to dismiss. Some examples of temporary system dialogs are the notification window-shade and the recent tasks dialog.

Constant Value: "android.intent.action.CLOSE_SYSTEM_DIALOGS"

This information can be found at android developer site.

Working example-

Android Manifest-

<receiver android:name=".SystemDialogReceiver">             <intent-filter>                 <action android:name="android.intent.                  action.CLOSE_SYSTEM_DIALOGS" />             </intent-filter> </receiver> 

Class file-

class SystemDialogReceiver extends BroadcastReceiver {         private static final String SYSTEM_DIALOG_REASON_KEY = "reason";         private static final String          SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";         @Override         public void onReceive(Context context, Intent intent) {              if(intent.getAction().equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)){                 String dialogType = intent.                 getStringExtra(SYSTEM_DIALOG_REASON_KEY);                 if(dialogType != null && dialogType.                 equals(SYSTEM_DIALOG_REASON_RECENT_APPS)){                     Intent closeDialog =                      new Intent(Intent.                     ACTION_CLOSE_SYSTEM_DIALOGS);                     context.sendBroadcast(closeDialog);                  }             }          }      } 
like image 38
My God Avatar answered Sep 24 '22 04:09

My God