Fix "java.lang.IllegalArgumentException: View not attached to window manager"