What is Activity?

A screen in the Android app’s user interface is called an Android activity. An Android app could have one or more screens, meaning that there may be many different activities on a single app. The main activity usually opens first to give the user access to these other activities.

Activity is a component that provides the user interface to do something. It can contain other components like views or services and it will be hosted by an Android system’s process, but there are exceptions for some apps which have their own processes. Activities can’t exist without Intents (which start them) or Intent Filters (which decide what they should do).

const val EXTRA_MESSAGE = "com.androidnames.test_app.MESSAGE"

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {

    fun sendMessage(view: View) {
        val editText = findViewById<EditText>(R.id.editText)
        val message = editText.text.toString()
        val intent = Intent(this, DisplayMessageActivity::class.java).apply {
            putExtra(EXTRA_MESSAGE, message)

Leave a Comment

Your email address will not be published.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.