DEV Community

Cover image for Activity in Android Development
Atharva Shirdhankar
Atharva Shirdhankar

Posted on • Edited on

1 1

Activity in Android Development

What is Activity in Android?
➡️ An activity represents a single screen with a user interface just like window

Lifecycle of Activity :
➡️ The Activity class defines the following call backs i.e. events.

Alt Text

PC:(Android Developers official website)

Methods:

1. OnCreate() :
➡️ This is the first callback and called when the activity is first created.

2. onStart() :
➡️ This callback is called when the activity becomes visible to the user.

3. onResume() :
➡️ This is called when the user starts interacting with the application.

4. onPause() :
➡️ The paused activity does not receive user input and cannot execute any code and called when the current activity is being paused and the previous activity is being resumed.

5. onStop() :
➡️ This callback is called when the activity is no longer visible.

6. onDestroy() :
➡️ This callback is called before the activity is destroyed by the system.

7. onRestart():
➡️ This callback is called when the activity restarts after stopping it.

Sentry mobile image

Is your mobile app slow? Improve performance with these key strategies.

Improve performance with key strategies like TTID/TTFD & app start analysis.

Read the blog post

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay