fix the crash bug caused by mainActivity is null