I am facing the similar issue explained in this link below. But the solution is not posted . Please help with the solution .
Android M ClassCastException: FrameLayout$LayoutParams cannot be cast to WindowManager$LayoutParams
No need to use a DialogActivity. Just add one more getParent() to access the container.
if (android.os.Build.VERSION.SDK_INT > 22) {
container = (View) pwindow.getContentView().getParent().getParent();
}else{
container = (View) pwindow.getContentView().getParent();
}