Show dialog alert from a non-activity class in android

后端 未结 7 2004
慢半拍i
慢半拍i 2020-12-06 02:37

I want to show an Alert Dialog via AlertDialogManager class to a non-activity class DeviceAdminReceiverSample\'s method onDisabl

7条回答
  •  一个人的身影
    2020-12-06 02:54

    Just add this before your alertDialog.show();

    alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    

    or try following if above didn't work:

    alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_PANEL); 
    

    and use this permission:

    
    

提交回复
热议问题