Skip to content
Android Development Explained — Beginner's Guide with Kotlin

Android Development Explained — Beginner's Guide with Kotlin

DodaTech Updated Jun 6, 2026 9 min read

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
  
Prerequisites: Familiarity with Kotlin basics (variables, functions, classes). See our Python tutorials if you need to learn programming fundamentals first. Install Android Studio from developer.android.com.

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:

  1. Activity — A single screen with a user interface (like a window in a desktop app)
  2. Service — Background processing (like downloading a file while the user does something else)
  3. Broadcast Receiver — Listens for system-wide events (like “battery low” or “WiFi connected”)
  4. 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:

MethodWhen It’s CalledWhat You Should Do
onCreate()First time the activity startsSet up UI, initialize variables
onStart()Activity becomes visibleStart animations, register listeners
onResume()Activity is ready for interactionStart camera, sensors, or GPS
onPause()Another activity is gaining focusSave unsaved data, stop animations
onStop()Activity is no longer visibleRelease heavy resources
onDestroy()Activity is being destroyedClean 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 AndroidX
  • onCreate() — The entry point, called when the activity starts. Think of it like main() in other languages
  • setContentView(R.layout.activity_main) — This tells Android which XML layout file to use for this screen. R.layout.activity_main refers to res/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:

  • LinearLayout arranges children vertically (or horizontally). match_parent means “take the full width of the screen”
  • TextView displays text. android:id gives it a unique name so Kotlin can reference it
  • EditText is a text input field. android:hint shows placeholder text inside the input
  • Button is clickable. android:onClick links 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 its android:id. Think of it like using a label to find a specific drawer in a filing cabinet
  • setOnClickListener — This attaches a function that runs when the button is tapped. The curly braces { } contain the code that executes
  • nameInput.text.toString() — Gets whatever the user typed and converts it to a Kotlin String
  • Toast.makeText(...) — Shows a brief popup message at the bottom of the screen. Toast.LENGTH_SHORT means it shows for about 2 seconds
  • Intent(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 class
  • intent.putExtra("USER_NAME", name) — This attaches data to the Intent so the next screen can read it
  • startActivity(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:

  1. First screen shows “Hello from DodaTech!” with an input field and button
  2. User types their name and taps “Greet Me”
  3. Second screen appears showing “Welcome, [Name]!”
  4. 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 InputFilter to restrict character types
  • Never trust data received from Intents (another app could send malicious Intent data)
  • Use Intent flags like FLAG_GRANT_READ_URI_PERMISSION when sharing sensitive data

Durga Antivirus Pro uses similar validation patterns when scanning file names and paths for malware signatures.

Common Mistakes Beginners Make

  1. Forgetting to register activities in AndroidManifest.xml: Your app will crash with ActivityNotFoundException.
  2. Memory leaks from holding Activity references: Never store an Activity in a static variable. It prevents garbage collection.
  3. Blocking the main thread: Network calls or heavy computation on the UI thread cause “Application Not Responding” (ANR) errors.
  4. Not handling configuration changes: When the user rotates the screen, Android recreates the Activity. Save state with onSaveInstanceState().
  5. Hardcoding strings instead of using string resources: Use res/values/strings.xml for all user-facing text. It makes translation and maintenance easier.
  6. Using dp for text sizes: Use sp (scale-independent pixels) for text so it respects the user’s font size settings.
  7. 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

  1. What method is called when an Activity first starts?
  2. What is an Intent used for in Android?
  3. Why do you need to register an Activity in AndroidManifest.xml?
  4. What does Toast.makeText() do?
  5. How do you pass data from one Activity to another?

Answers:

  1. onCreate() — it’s the entry point for the Activity lifecycle.
  2. Intents are used to navigate between components (starting Activities, Services, or sending broadcast messages).
  3. Android needs to know all app components exist at build time. Unregistered activities cause crashes.
  4. It displays a brief popup message at the bottom of the screen.
  5. Use intent.putExtra(key, value) to send and intent.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

What’s the difference between dp and sp in Android layouts?
dp (density-independent pixels) keeps physical sizes consistent across screens. sp (scale-independent pixels) does the same but also respects the user’s font size setting. Use sp for text, dp for everything else.
Do I need a real device to test Android apps?
No, Android Studio includes an emulator. But testing on a real device is recommended because emulators can’t perfectly replicate battery behavior, camera quality, or sensor accuracy.
What is an APK?
APK (Android Package Kit) is the installable file format for Android apps. It contains compiled code, resources, and the manifest. Android Studio generates it when you build your app.
Can I use Java instead of Kotlin for Android development?
Yes, Java is fully supported. However, Google recommends Kotlin as the preferred language because it’s more concise, safer (null safety), and has better modern language features.

Try It Yourself

▶ Try It Yourself Edit the code and click Run

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