fixed the runtime error which cause when switch acitvities