Android Development Explained — Beginner's Guide with Kotlin
Android development with Kotlin lets you build applications for billions of devices worldwide using a modern, concise language and Android’s component-based architecture for creating rich mobile experiences.
What You’ll Learn
You’ll understand the Android Activity lifecycle, create XML layouts, use Intents to navigate between screens, and build your first complete “Hello World” Android app with Kotlin.
Why Android Development Matters
Android powers over 70% of the world’s smartphones. From banking apps to social media to security tools like Durga Antivirus Pro (which has an Android scanning module), the platform is everywhere. At DodaTech, our Doda Browser is an Android app used by thousands. Learning Android development lets you build for the world’s largest mobile ecosystem.
Android Development Learning Path
flowchart LR
A[Mobile Development Overview] --> B[Android Development]
B --> C[Layouts & Views]
C --> D[Intents & Navigation]
D --> E[Data Persistence]
E --> F[Networking & APIs]
F --> G[Publishing to Play Store]
B:::current
classDef current fill:#f90,color:#fff,stroke:#333,stroke-width:2px
Understanding Android’s Architecture
Think of an Android app as a collection of independent components that the system can start and stop as needed. The four main types are:
- Activity — A single screen with a user interface (like a window in a desktop app)
- Service — Background processing (like downloading a file while the user does something else)
- Broadcast Receiver — Listens for system-wide events (like “battery low” or “WiFi connected”)
- Content Provider — Shares data between apps (like contacts)
For this tutorial, we’ll focus on Activities — the most fundamental component.
The Activity Lifecycle
Every Android Activity goes through a specific set of states from creation to destruction. Understanding this lifecycle is critical because your app must handle interruptions gracefully.
stateDiagram-v2
[*] --> onCreate: App starts
onCreate --> onStart
onStart --> onResume: Ready for user
onResume --> onPause: Another app overlaps
onPause --> onResume: Return to app
onPause --> onStop: App no longer visible
onStop --> onRestart: User navigates back
onRestart --> onStart
onStop --> onDestroy: System kills app
onDestroy --> [*]
Why does this matter? Imagine a user is writing a note in your app and gets a phone call. Without lifecycle handling, their text would be lost. With proper lifecycle management, you save the draft in onPause() and restore it in onResume().
Key methods to override:
| Method | When It’s Called | What You Should Do |
|---|---|---|
onCreate() | First time the activity starts | Set up UI, initialize variables |
onStart() | Activity becomes visible | Start animations, register listeners |
onResume() | Activity is ready for interaction | Start camera, sensors, or GPS |
onPause() | Another activity is gaining focus | Save unsaved data, stop animations |
onStop() | Activity is no longer visible | Release heavy resources |
onDestroy() | Activity is being destroyed | Clean up all references |
Building Your First Android App
Let’s build a simple app that greets the user and navigates to a second screen.
Step 1: Create a New Project
Open Android Studio and choose New Project > Empty Views Activity. Name it “HelloDodaTech” and select Kotlin.
Android Studio generates this code automatically:
package com.example.hellododatech
import android.os.Bundle
import androidx.activity.ComponentActivity
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}Let’s break down what this does:
package com.example.hellododatech— This is your app’s unique identifier (like a domain name)class MainActivity : ComponentActivity()— This declares your main screen. It extends ComponentActivity, which is the base class for activities using AndroidXonCreate()— The entry point, called when the activity starts. Think of it likemain()in other languagessetContentView(R.layout.activity_main)— This tells Android which XML layout file to use for this screen.R.layout.activity_mainrefers tores/layout/activity_main.xml
Step 2: Design the Layout
Open res/layout/activity_main.xml. This is where you define what the user sees:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:padding="32dp">
<TextView
android:id="@+id/titleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello from DodaTech!"
android:textSize="28sp"
android:textStyle="bold" />
<EditText
android:id="@+id/nameInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter your name"
android:inputType="text"
android:padding="12dp" />
<Button
android:id="@+id/greetButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Greet Me"
android:onClick="onGreetClicked" />
</LinearLayout>Understanding the XML:
LinearLayoutarranges children vertically (or horizontally).match_parentmeans “take the full width of the screen”TextViewdisplays text.android:idgives it a unique name so Kotlin can reference itEditTextis a text input field.android:hintshows placeholder text inside the inputButtonis clickable.android:onClicklinks it to a function in our Kotlin code
Step 3: Write the Kotlin Logic
Now let’s update MainActivity.kt to handle the button click and navigate to a second screen:
package com.example.hellododatech
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import android.widget.TextView
import android.widget.Toast
import androidx.activity.ComponentActivity
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Find our UI elements by their IDs
val nameInput: EditText = findViewById(R.id.nameInput)
val greetButton: Button = findViewById(R.id.greetButton)
val titleText: TextView = findViewById(R.id.titleText)
// Set a click listener on the button
greetButton.setOnClickListener {
val name = nameInput.text.toString()
if (name.isBlank()) {
// Show a popup message if the user didn't enter a name
Toast.makeText(this, "Please enter a name!", Toast.LENGTH_SHORT).show()
} else {
// Create an Intent to navigate to GreetingActivity
val intent = Intent(this, GreetingActivity::class.java)
intent.putExtra("USER_NAME", name)
startActivity(intent)
}
}
}
}What’s happening here?
findViewById(R.id.nameInput)— This finds the EditText we defined in the XML by itsandroid:id. Think of it like using a label to find a specific drawer in a filing cabinetsetOnClickListener— This attaches a function that runs when the button is tapped. The curly braces{ }contain the code that executesnameInput.text.toString()— Gets whatever the user typed and converts it to a Kotlin StringToast.makeText(...)— Shows a brief popup message at the bottom of the screen.Toast.LENGTH_SHORTmeans it shows for about 2 secondsIntent(this, GreetingActivity::class.java)— An Intent is like a command telling Android “I want to go to this screen.” We pass the current activity (this) and the target classintent.putExtra("USER_NAME", name)— This attaches data to the Intent so the next screen can read itstartActivity(intent)— This actually launches the second screen
Step 4: Create the Second Activity
Create a new Kotlin class called GreetingActivity.kt:
package com.example.hellododatech
import android.os.Bundle
import android.widget.TextView
import androidx.activity.ComponentActivity
class GreetingActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_greeting)
// Get the name passed from MainActivity
val userName = intent.getStringExtra("USER_NAME") ?: "Friend"
// Display the greeting
val greetingText: TextView = findViewById(R.id.greetingText)
greetingText.text = "Welcome, $userName!"
}
}Notice intent.getStringExtra("USER_NAME") — this reads the data we sent. The ?: "Friend" part is the Elvis operator (looks like a sideways smiley). It says: “If getStringExtra returns null, use ‘Friend’ instead.” This prevents crashes if the data wasn’t passed correctly.
Create the layout file res/layout/activity_greeting.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:padding="32dp">
<TextView
android:id="@+id/greetingText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="32sp"
android:textStyle="bold" />
</LinearLayout>Step 5: Register the Activity
Add GreetingActivity to your AndroidManifest.xml (inside the <application> tag):
<activity android:name=".GreetingActivity" />Without this, Android doesn’t know your second screen exists. It’s like adding a new room to a house — you need to update the floor plan.
Expected Output
When you run the app on an emulator or device:
- First screen shows “Hello from DodaTech!” with an input field and button
- User types their name and taps “Greet Me”
- Second screen appears showing “Welcome, [Name]!”
- The back button returns to the first screen
Security Angle: Protecting User Input
In the code above, we check name.isBlank() before processing. This is a basic security practice called input validation. Malicious users can inject harmful data through text fields. In production apps, always:
- Validate and sanitize user input on both client and server
- Use
InputFilterto restrict character types - Never trust data received from Intents (another app could send malicious Intent data)
- Use
Intentflags likeFLAG_GRANT_READ_URI_PERMISSIONwhen sharing sensitive data
Durga Antivirus Pro uses similar validation patterns when scanning file names and paths for malware signatures.
Common Mistakes Beginners Make
- Forgetting to register activities in AndroidManifest.xml: Your app will crash with
ActivityNotFoundException. - Memory leaks from holding Activity references: Never store an Activity in a static variable. It prevents garbage collection.
- Blocking the main thread: Network calls or heavy computation on the UI thread cause “Application Not Responding” (ANR) errors.
- Not handling configuration changes: When the user rotates the screen, Android recreates the Activity. Save state with
onSaveInstanceState(). - Hardcoding strings instead of using string resources: Use
res/values/strings.xmlfor all user-facing text. It makes translation and maintenance easier. - Using
dpfor text sizes: Usesp(scale-independent pixels) for text so it respects the user’s font size settings. - Not requesting runtime permissions: On Android 6.0+, dangerous permissions like camera and location must be requested while the app is running, not just declared in the manifest.
Practice Questions
- What method is called when an Activity first starts?
- What is an Intent used for in Android?
- Why do you need to register an Activity in AndroidManifest.xml?
- What does
Toast.makeText()do? - How do you pass data from one Activity to another?
Answers:
onCreate()— it’s the entry point for the Activity lifecycle.- Intents are used to navigate between components (starting Activities, Services, or sending broadcast messages).
- Android needs to know all app components exist at build time. Unregistered activities cause crashes.
- It displays a brief popup message at the bottom of the screen.
- Use
intent.putExtra(key, value)to send andintent.getStringExtra(key)to receive.
Challenge
Add a third screen that shows the user’s name in reverse order (e.g., “Alex” becomes “xelA”). Pass the name from MainActivity through GreetingActivity to the new screen using Intents.
Real-World Task
Modify the app to include a “Share” button on the greeting screen. Use Android’s ShareCompat.IntentBuilder to open the system share sheet so the user can send their greeting via WhatsApp, email, or messaging apps.
Featured Snippet
What is the Android Activity lifecycle?
The Android Activity lifecycle is a set of states an activity transitions through — onCreate, onStart, onResume, onPause, onStop, and onDestroy — allowing apps to handle interruptions, save state, and manage resources properly.
FAQ
Try It Yourself
What’s Next
What’s Next
Congratulations on completing this Android Development tutorial! Here’s where to go from here:
- Practice daily — Consistency is more important than long study sessions
- Build a project — Apply what you learned by building something real
- Explore related topics — Check out other tutorials in the same category
- Join the community — Discuss with other learners and share your progress
Remember: every expert was once a beginner. Keep coding!
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro