2. • An activity is a fundamental component of an app that represents a single,
focused screen with a user interface. Activities are used to interact with the
user and typically correspond to the various screens or windows the user
can interact with in an app.
• Activities can communicate with each other by passing data through intents.
Intents are a mechanism for sending messages between activities, which can
be used to start new activities or pass information between them.
Activities and Intents
4. package com.a2k.myapplication
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val intent = Intent(this, AnotherActivity::class.java)
startActivity(intent)
finish()
}
}
5. • Android views are the basic building blocks of the user interface (UI). They
are small rectangular boxes that respond to user inputs. Examples of views
include Text View, Edit Text, Button, Check Box, etc.
• View Group is an invisible container of other views and other View Groups.
Some of the view groups are Linear Layout, Constraint Layout, Relative
Layout, etc.
Android Views
6. • To share data between activities in Android, you can use an Intent. An
Intent is a messaging object that can launch a new Activity by passing it to
the startActivity() method. Intent can also carry data with various putExtra()
methods, in key-value pairs.
Sharing Data b/w Activities
10. A Fragment represents a reusable portion of your app's UI. A fragment
defines and manages its own layout, has its own lifecycle, and can handle its
own input events. Fragments can't live on their own. They must be hosted by
an activity or another fragment.
Learn More
Fragments