Bird
Raised Fist0
Android Kotlinmobile~20 mins

Why Android dominates mobile market share in Android Kotlin - Build It to Prove It

Choose your learning style10 modes available
Build: Market Share Info
This screen shows reasons why Android dominates the mobile market share in a simple list format.
Target UI
-------------------------
| Market Share Info      |
|-----------------------|
| Reasons Android Wins:  |
| 1. Open Source        |
| 2. Wide Device Range  |
| 3. Affordable Prices  |
| 4. Customization      |
| 5. Google Services    |
|                       |
| [Refresh]             |
-------------------------
Display a title at the top
Show a numbered list of 5 reasons why Android dominates
Add a Refresh button at the bottom
When Refresh is tapped, show a Toast message 'Data refreshed!'
Starter Code
Android Kotlin
package com.example.marketshareinfo

import android.os.Bundle
import android.widget.Button
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView

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

        // TODO: Initialize RecyclerView and Button here
    }
}
Task 1
Task 2
Task 3
Solution
Android Kotlin
package com.example.marketshareinfo

import android.os.Bundle
import android.widget.Button
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView

class MainActivity : AppCompatActivity() {
    private val reasons = listOf(
        "Open Source",
        "Wide Device Range",
        "Affordable Prices",
        "Customization",
        "Google Services"
    )

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val recyclerView = findViewById<RecyclerView>(R.id.recyclerView)
        recyclerView.layoutManager = LinearLayoutManager(this)
        recyclerView.adapter = ReasonsAdapter(reasons)

        val refreshButton = findViewById<Button>(R.id.refreshButton)
        refreshButton.setOnClickListener {
            Toast.makeText(this, "Data refreshed!", Toast.LENGTH_SHORT).show()
        }
    }
}

class ReasonsAdapter(private val items: List<String>) : RecyclerView.Adapter<ReasonsAdapter.ViewHolder>() {
    class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        val textView: TextView = view.findViewById(R.id.reasonText)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.reason_item, parent, false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.textView.text = "${position + 1}. ${items[position]}"
    }

    override fun getItemCount(): Int = items.size
}

This app screen uses a RecyclerView to show a numbered list of reasons why Android dominates the mobile market. The list is simple and fixed. The Refresh button at the bottom shows a Toast message when tapped, simulating a data refresh.

The RecyclerView uses a LinearLayoutManager for vertical scrolling. The adapter binds each reason with its number prefix. This keeps the UI clean and easy to read.

This approach is common in Android apps to display lists efficiently and handle user actions like button taps.

Final Result
Completed Screen
-------------------------
| Market Share Info      |
|-----------------------|
| Reasons Android Wins:  |
| 1. Open Source        |
| 2. Wide Device Range  |
| 3. Affordable Prices  |
| 4. Customization      |
| 5. Google Services    |
|                       |
| [Refresh]             |
-------------------------
User taps Refresh button
A small popup (Toast) appears with text 'Data refreshed!'
Stretch Goal
Add a dark mode toggle button that switches the screen background and text colors.
💡 Hint
Use AppCompatDelegate.setDefaultNightMode() to switch between MODE_NIGHT_YES and MODE_NIGHT_NO.

Practice

(1/5)
1. Why does Android have a larger market share compared to other mobile operating systems?
easy
A. Because it has fewer users worldwide
B. Because it only runs on expensive phones
C. Because it is open source and available on many devices
D. Because it restricts app development

Solution

  1. Step 1: Understand Android's openness

    Android is open source, meaning anyone can use and modify it freely.
  2. Step 2: Recognize device availability

    It runs on many types of devices, from budget to premium, increasing its reach.
  3. Final Answer:

    Because it is open source and available on many devices -> Option C
  4. Quick Check:

    Open source + wide availability = Android's market lead [OK]
Hint: Open source and device variety boost Android's share [OK]
Common Mistakes:
  • Thinking Android is only for expensive phones
  • Believing Android restricts app development
  • Assuming Android has fewer users
2. Which Kotlin syntax correctly declares a variable for Android device count?
easy
A. var deviceCount := 1000
B. val deviceCount == 1000
C. deviceCount = 1000 val
D. val deviceCount = 1000

Solution

  1. Step 1: Recall Kotlin variable declaration

    Kotlin uses 'val' for immutable variables and '=' for assignment.
  2. Step 2: Check each option's syntax

    val deviceCount = 1000 uses correct syntax: 'val deviceCount = 1000'. Others misuse ':=', '==', or order.
  3. Final Answer:

    val deviceCount = 1000 -> Option D
  4. Quick Check:

    Use 'val' + '=' for variable declaration [OK]
Hint: Use 'val' and '=' to declare variables in Kotlin [OK]
Common Mistakes:
  • Using ':=' instead of '='
  • Placing 'val' after variable name
  • Using '==' for assignment
3. What will this Kotlin code print about Android's market share?
val androidUsers = 3000
val iosUsers = 1000
println("Android leads by ${androidUsers - iosUsers} million users")
medium
A. Android leads by 1000 million users
B. Android leads by 2000 million users
C. Android leads by 4000 million users
D. Syntax error

Solution

  1. Step 1: Calculate user difference

    androidUsers - iosUsers = 3000 - 1000 = 2000
  2. Step 2: Understand string interpolation

    The expression inside ${} is evaluated and inserted into the string.
  3. Final Answer:

    Android leads by 2000 million users -> Option B
  4. Quick Check:

    3000 - 1000 = 2000 [OK]
Hint: Subtract user counts inside ${} for correct output [OK]
Common Mistakes:
  • Adding instead of subtracting users
  • Misunderstanding string interpolation
  • Expecting syntax error
4. Identify the error in this Kotlin snippet about Android device count:
var deviceCount: Int = "1000"
println(deviceCount)
medium
A. Type mismatch: String assigned to Int variable
B. Missing semicolon after declaration
C. Variable deviceCount not declared
D. Correct code, no error

Solution

  1. Step 1: Check variable type and assigned value

    deviceCount is declared as Int but assigned a String "1000".
  2. Step 2: Understand Kotlin type safety

    Kotlin does not allow assigning String to Int without conversion.
  3. Final Answer:

    Type mismatch: String assigned to Int variable -> Option A
  4. Quick Check:

    Int variable must get Int value [OK]
Hint: Match variable type with assigned value type [OK]
Common Mistakes:
  • Ignoring type mismatch errors
  • Thinking semicolons are required
  • Assuming implicit conversion
5. How does Android's open-source nature help manufacturers increase market share?
hard
A. It allows manufacturers to customize Android freely for different devices
B. It forces manufacturers to pay high licensing fees
C. It restricts manufacturers to only one device model
D. It limits app availability on devices

Solution

  1. Step 1: Understand open-source benefits for manufacturers

    Manufacturers can modify Android to fit various hardware and features without extra cost.
  2. Step 2: Recognize impact on market share

    This flexibility lets many manufacturers produce diverse devices, increasing Android's market presence.
  3. Final Answer:

    It allows manufacturers to customize Android freely for different devices -> Option A
  4. Quick Check:

    Open source = free customization = more devices [OK]
Hint: Open source means free customization for manufacturers [OK]
Common Mistakes:
  • Thinking open source means high fees
  • Believing manufacturers are limited to one model
  • Assuming app availability is restricted
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard