Fix issue of crashing when OnResume