Skip to content

jreategui07/ActivityLifecycleApp_Android

Repository files navigation

Android Activity Lifecycle Demo App

Description

This Android application demonstrates the Activity Lifecycle in Android applications. It logs and showcases the execution of lifecycle events such as onCreate, onStart, onResume, onPause, onStop, onRestart, and onDestroy. The project is implemented using Java, Kotlin with XML and Jetpack Compose.

Features

  • Java: To demonstrates the Activity Lifecycle using Java + XML.
  • Kotlin: To demonstrates the Activity Lifecycle using Kotlin + XML.
  • Jetpack Compose: To demonstrates the Activity Lifecycle using Compose.
  • Intent: To navigate between activities.

Required Configuration

  • No additional configuration is required.

Lifecycle Events and Examples

Event Description Common Use Cases
onCreate() Called when the Activity is created. Initializes the UI, data structures, and other components.
  • Initialize the UI.
  • Set up ViewModels, adapters, and bindings.
onStart() Called when the Activity becomes visible to the user but is not yet interactive.
  • Load lightweight data.
  • Start animations.
onResume() Called when the Activity is ready to interact with the user (foreground).
  • Start API requests.
  • Resume animations, playback, or sensor listeners.
onPause() Called when the Activity is no longer in the foreground but still partially visible. Used to save state and release temporary resources.
  • Pause animations or video playback.
  • Save unsaved changes.
onStop() Called when the Activity is no longer visible to the user.
  • Release resources like network connections.
  • Save app state.
onRestart() Called when the Activity is restarting after being stopped.
  • Reinitialize components or refresh data if needed.
onDestroy() Called when the Activity is being destroyed. It’s the last callback received.
  • Release memory and resources.
  • Clean up listeners, threads, or ViewModels.

Demo

Here are some screenshots of the application:

License License: MIT

The MIT License (MIT)

  • Copyright (c) 2024 Jonathan Reátegui

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Notes

  • This README is also available in Spanish here
  • Este README también está disponible en español aquí

About

This Android application demonstrates the Activity Lifecycle in Android applications. It logs and showcases the execution of lifecycle events such as onCreate, onStart, onResume, onPause, onStop, onRestart, and onDestroy.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors