Code example for Context

Methods: registerReceiver

0
        public Dialog dialog;
 
        CloseDialogReceiver(Context context) {
            mContext = context;
            IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
            context.registerReceiver(this, filter);
        } 
 
        @Override 
        public void onReceive(Context context, Intent intent) {
            dialog.cancel();
        } 
 
        public void onDismiss(DialogInterface unused) {
            mContext.unregisterReceiver(this);
        } 
    } 
 
    /** 
     * Request a clean shutdown, waiting for subsystems to clean up their 
     * state etc.  Must be called from a Looper thread in which its UI