juniorAndroid

What is Activity vs Fragment?

Updated Feb 20, 2026

Short answer

Activity represents a screen, while Fragment represents a reusable UI component inside an Activity.

Deep explanation

🔹 Activity

  • Entry point
  • Lifecycle managed by system

🔹 Fragment

  • Reusable
  • Flexible UI

---

🖼️

Markdown
![Activity vs Fragment](https://developer.android.com/static/images/guide/fragments/fragment_lifecycle.png)

---

🔹 Modern Use

  • Single Activity + multiple Fragments or Compose screens

Real-world example

WhatsApp uses fragments for chat, status, and calls screens.

Common mistakes

  • Overusing activities
  • Fragment lifecycle issues

Follow-up questions

  • Fragment lifecycle?
  • Why single-activity pattern?

More Android interview questions

View all →