Fixed the null pointer exception when returning to the main activity