App lifecycle code added to MainActivity.