Fix nullpointerexception:make sure dialog is not null

Fix nullpointerexception:make sure dialog is not null