Adding the life cycle in MainActivity

- Adding the life cycle in MainActivity