Sobes.tech
Junior — Middle

What is the role of the Activity component in an Android application?

sobes.tech AI

Answer from AI

An Activity in Android is a component that represents a single screen with a user interface. It is responsible for:

  • Displaying the UI and interacting with the user.
  • Managing the lifecycle of the screen (creation, pause, resume, destruction).
  • Launching other Activities and receiving results from them.

Example of a simple Activity in Kotlin:

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main) // bind layout
    }
}

Activity is the main building block for creating screens in Android applications.

What is the role of the Activity component in an… - sobes.tech