issue #24 code optimization for DialogActivity and WifiDirectActivity