SlideShare a Scribd company logo
This work is licensed under the Apache 2.0 License
This work is licensed under the Apache 2.0 License
Learn fundamentals of Kotlin, object-oriented
programming, and lambdas.
Kotlin Fundamentals
This work is licensed under the Apache 2.0 License
‘IF KEYWORD’ +
‘CONDITION YOU NEED TO
EVALUATE’
BOOLEAN EXPRESSION
Expressions combine values, variables,
and operators that return a value.
Boolean expressions return a boolean
value.
Use If/else statements to express
conditions
This work is licensed under the Apache 2.0 License
Use a when statement for multiple branches
In Kotlin, when you deal with multiple branches, you can use the
when statement instead of the if/else statement because it
improves readability, which refers to how easy it is for human
readers, typically developers, to read the code. It's very important
to consider readability when you write your code because it's likely
that other developers need to review and modify your code
throughout its lifetime
This work is licensed under the Apache 2.0 License
Use nullable variables
1)What is null?
In Unit 1, you learned that when you declare a variable, you need to assign it
a value immediately. For example, when you declare a favorite Actor
variable, you may assign it a "Sandra Oh" string value immediately.
However, what if you don't have a favorite actor? You might want to assign
the variable a "Nobody" or "None" value. This isn't a good approach because
your program interprets the favorite Actor variable to have a "Nobody" or "None"
value rather than no value at all. In Kotlin, you can use null to indicate that
there's no value associated with the variable.
This work is licensed under the Apache 2.0 License
Handle nullable variables
Previously, you learned to use the . operator to access methods and
properties of non-nullable variables. In this section, you learn how to
use it to access methods and properties of nullable variables
fun main() {
var favoriteActor: String = "Sandra Oh"
println(favoriteActor.length)
}
This work is licensed under the Apache 2.0 License
Add a button to an app
Learn how to respond to a button
click in an Android app.
This work is licensed under the Apache 2.0 License
Define a class
1)A class definition starts with the class
keyword, followed by a name and a set of curly
braces.
2)The part of the syntax before the opening curly
brace is also referred to as the class header. In
the curly braces, you can specify properties and
functions for the class.
This work is licensed under the Apache 2.0 License
Create an instance of a class
1)To use an object, you create the object and assign it to a variable,
similar to how you define a variable. You use the val keyword to create
an immutable variable and the var keyword for a mutable variable.
2)The val or var keyword is followed by the name of the variable, then
an = assignment operator, then the instantiation of the class object. You
can see the syntax in this diagram:
This work is licensed under the Apache 2.0 License
Define class methods
Call a method on an object
This work is licensed under the Apache 2.0 License
Define class properties
Properties are basically variables that are defined in the class
body instead of the function body. This means that the syntax
to define properties and variables are identical.
● Define a constructor
1. Default constructor 2. parameterized constructor
Syntax :
● syntax to specify a visibility modifier for a property
Visibility modifiers
● syntax to specify a visibility modifier for a method
Visibility modifiers
Kotlin Practice :
CODE :
OUTPUT:
SOLUTION CODE:
This work is licensed under the Apache 2.0 License
. Create an interactive Dice Roller app
● Establish a baseline
● Create the layout infrastructure
● Create a vertical
layout
● Add a button
● Add an image
● Add an Image
composable
● Build the dice-roll logic
● Use the debugger in Android Studio
● Run the app with the debugger
● Practice: Click behavior
App overview
● LOGIC BUILDING
● FINAL APP VIEW
This work is licensed under the Apache 2.0 License
COMPOSE CAMP
SESSION 2
This work is licensed under the Apache 2.0 License
Pathway 3:
Interact with UI
and state
Activity 1: Intro to state in Compose
Activity 2:Calculate a custom tip
Activity 3:Write automated tests
Activity 4:Project: Create an Art Space app
Create a tip calculator app that calculates the tip from user input in the app.
This work is licensed under the Apache 2.0 License
Activity 1: Intro to state in Compose
What you'll learn
● How to think about state in a UI.
● How Compose uses state to display data.
● How to add a text box to your app.
● How to hoist a state.
What you'll build
● A tip-calculator app called Tip Time that calculates a tip amount based
on the service amount.
This work is licensed under the Apache 2.0 License
This work is licensed under the Apache 2.0 License
This work is licensed under the Apache 2.0 License
Create a project.
<resources>
<string name="app_name">Tip Time</string>
<string name="calculate_tip">Calculate Tip</string>
<string name="cost_of_service">Cost of Service</string>
<string name="tip_amount">Tip amount: %s</string>
</resources>
This work is licensed under the Apache 2.0 License
Add a screen title
override fun onCreate(savedInstanceState: Bundle?) {
//...
setContent {
TipTimeTheme {
Surface(
//...
) {
TipTimeScreen()
}
}
}
}
This work is licensed under the Apache 2.0 License
@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
TipTimeTheme {
TipTimeScreen()
}
}
Column(
modifier = Modifier.padding(32.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {}
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.ui.unit.dp
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.sp
import androidx.compose.ui.Alignment
Text(
text = stringResource(R.string.calculate_tip),
fontSize = 24.sp,
modifier = Modifier.align(Alignment.CenterHorizontally)
)
Add the TextField composable
import androidx.compose.material.TextField
@Composable
fun TipTimeScreen() {
Column(
modifier = Modifier.padding(32.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
Text(
...
)
Spacer(Modifier.height(16.dp))
EditNumberField()
}
}
This work is licensed under the Apache 2.0 License
6. Use state in Compose
val amountInput = "0"
This work is licensed under the Apache 2.0 License
7. The composition
@Composable
fun EditNumberField() {
var amountInput = mutableStateOf("0")
TextField(
value = amountInput.value,
onValueChange = { amountInput.value = it },
)
}
This work is licensed under the Apache 2.0 License
8. Use remember function to save state
Warning: This code may throw the error that you see in this image regarding the getValue() extension function:
If so, manually add the getValue and setValue imports into the import block at the beginning of the file as you can see in
this image:
This work is licensed under the Apache 2.0 License
Warning: This code may throw the error that you see in this image regarding the getValue() extension function:
If so, manually add the getValue and setValue imports into the import block at the beginning of the file as you
can see in this image:
This work is licensed under the Apache 2.0 License
@Composable
fun EditNumberField() {
var amountInput by remember { mutableStateOf("") }
TextField(
value = amountInput,
onValueChange = { amountInput = it },
)
}
This work is licensed under the Apache 2.0 License
9. State and recomposition in action
This work is licensed under the Apache 2.0 License
10. Modify the appearance
This work is licensed under the Apache 2.0 License
@Composable
fun EditNumberField() {
var amountInput by remember { mutableStateOf("") }
TextField(
value = amountInput,
onValueChange = { amountInput = it },
label = { Text(stringResource(R.string.cost_of_service)) },
modifier = Modifier.fillMaxWidth(),
singleLine = true,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number)
)
}
This work is licensed under the Apache 2.0 License
This work is licensed under the Apache 2.0 License
11. Display the tip amount
This work is licensed under the Apache 2.0 License
private fun calculateTip(
amount: Double,
tipPercent: Double = 15.0
): String {
val tip = tipPercent / 100 * amount
return NumberFormat.getCurrencyInstance().format(tip)
}
This work is licensed under the Apache 2.0 License
@Composable
fun EditNumberField() {
var amountInput by remember { mutableStateOf("") }
val amount = amountInput.toDoubleOrNull() ?: 0.0
val tip = calculateTip(amount)
TextField(
value = amountInput,
onValueChange = { amountInput = it },
label = { Text(stringResource(R.string.cost_of_service)) },
modifier = Modifier.fillMaxWidth(),
singleLine = true,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number)
)
}
This work is licensed under the Apache 2.0 License
Show the calculated tip amount
This work is licensed under the Apache 2.0 License
@Composable
fun TipTimeScreen() {
Column(
//...
) {
Text(
text = stringResource(R.string.tip_amount, ""),
modifier = Modifier.align(Alignment.CenterHorizontally),
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
EditNumberField()
Spacer(Modifier.height(24.dp))
}
}
This work is licensed under the Apache 2.0 License
12. State hosting
Understand stateful versus stateless composables
You should hoist the state when you need to:
● Share the state with multiple composable functions.
● Create a stateless composable that can be reused in your app.
This work is licensed under the Apache 2.0 License
@Composable
fun TipTimeScreen() {
var amountInput by remember { mutableStateOf("") }
val amount = amountInput.toDoubleOrNull() ?: 0.0
val tip = calculateTip(amount)
Column(
modifier = Modifier.padding(32.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
Text(
text = stringResource(R.string.calculate_tip),
fontSize = 24.sp,
modifier = Modifier.align(Alignment.CenterHorizontally)
)
Spacer(Modifier.height(16.dp))
EditNumberField(value = amountInput,
onValueChange = { amountInput = it }
)
Spacer(Modifier.height(24.dp))
Text(
text = stringResource(R.string.tip_amount, tip),
modifier = Modifier.align(Alignment.CenterHorizontally),
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
}
}
This work is licensed under the Apache 2.0 License
@Composable
fun EditNumberField(
value: String,
onValueChange: (String) -> Unit
) {
TextField(
value = value,
onValueChange = onValueChange,
label = { Text(stringResource(R.string.cost_of_service)) },
modifier = Modifier.fillMaxWidth(),
singleLine = true,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number)
)
}
This work is licensed under the Apache 2.0 License
This work is licensed under the Apache 2.0 License
13. Get the solution
To download the code for the finished activity,
you can download the repository as a zip file, unzip it, and open it in Android Studio.
This work is licensed under the Apache 2.0 License
Conclusion.
Congratulations! You completed this codelab and learned how to use state in a
Compose app!
Summary
● State in an app is any value that can change over time.
● The Composition is a description of the UI built by Compose when it executes
composables. Compose apps call composable functions to transform data into UI.
● Initial composition is a creation of the UI by Compose when it executes
composable functions the first time.
● Recomposition is the process of running the same composables again to update
the tree when their data changes.
● State hoisting is a pattern of moving state up to make a component stateless.
This work is licensed under the Apache 2.0 License
Activity 4: calculate a custom tip
This work is licensed under the Apache 2.0 License
What you'll learn
● How to add an action button to a virtual keyboard.
● How to set up keyboard actions.
● What a Switch composable is and how to use it.
● What the Layout Inspector is.
What you'll build
● A Tip Time App that calculates tip amounts based on the user's inputted
cost of service and tip percentage.
This work is licensed under the Apache 2.0 License
Starter app overview
This work is licensed under the Apache 2.0 License
4. Add a tip-percentage text
field
@Composable
fun EditNumberField(
@StringRes label: Int,
value: String,
onValueChange: (String) -> Unit,
modifier: Modifier = Modifier
) {
TextField(
//...
label = { Text(stringResource(label)) },
//...
)
}
This work is licensed under the Apache 2.0 License
EditNumberField(
label = R.string.how_was_the_service,
value = "",
onValueChange = { }
)
EditNumberField(
label = R.string.how_was_the_service,
value = tipInput,
onValueChange = { tipInput = it }
)
This work is licensed under the Apache 2.0 License
@Composable
fun TipTimeScreen() {
var amountInput by remember { mutableStateOf("") }
var tipInput by remember { mutableStateOf("") }
val tipPercent = tipInput.toDoubleOrNull() ?: 0.0
val amount = amountInput.toDoubleOrNull() ?: 0.0
val tip = calculateTip(amount, tipPercent)
Column(
modifier = Modifier.padding(32.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
Text(
text = stringResource(R.string.calculate_tip),
fontSize = 24.sp,
modifier = Modifier.align(Alignment.CenterHorizontally)
)
Spacer(Modifier.height(16.dp))
EditNumberField(
label = R.string.bill_amount,
value = amountInput,
onValueChange = { amountInput = it }
)
EditNumberField(
label = R.string.how_was_the_service,
value = tipInput,
onValueChange = { tipInput = it }
)
Spacer(Modifier.height(24.dp))
Text(
text = stringResource(R.string.tip_amount, tip),
modifier =
Modifier.align(Alignment.CenterHorizontally),
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
}
}
This work is licensed under the Apache 2.0 License
This work is licensed under the Apache 2.0 License
5. Set an action button
@Composable
fun EditNumberField(
//...
) {
TextField(
//...
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.Number,
imeAction = ImeAction.Next
)
)
}
This work is licensed under the Apache 2.0 License
This work is licensed under the Apache 2.0 License
@Composable
fun EditNumberField(
@StringRes label: Int,
keyboardOptions: KeyboardOptions,
value: String,
onValueChange: (String) -> Unit
){
TextField(
//...
keyboardOptions = keyboardOptions
)
} EditNumberField(
label = R.string.how_was_the_service,
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Number,
imeAction = ImeAction.Done
),
value = tipInput,
onValueChange = { tipInput = it }
)
This work is licensed under the Apache 2.0 License
This work is licensed under the Apache 2.0 License
7. Add a switch
This work is licensed under the Apache 2.0 License
@Composable
fun RoundTheTipRow(roundUp: Boolean, onRoundUpChanged: (Boolean) -> Unit) {
Row(
modifier = Modifier
.fillMaxWidth()
.size(48.dp),
verticalAlignment = Alignment.CenterVertically
) {
Text(stringResource(R.string.round_up_tip))
Switch(
modifier = Modifier
.fillMaxWidth()
.wrapContentWidth(Alignment.End),
checked = roundUp,
onCheckedChange = onRoundUpChanged,
colors = SwitchDefaults.colors(
uncheckedThumbColor = Color.DarkGray
)
)
}
}
This work is licensed under the Apache 2.0 License
1. Thumb
2. Track
This work is licensed under the Apache 2.0 License
private fun calculateTip(amount: Double, tipPercent: Double = 15.0, roundUp:
Boolean): String {
var tip = tipPercent / 100 * amount
if (roundUp)
tip = kotlin.math.ceil(tip)
return NumberFormat.getCurrencyInstance().format(tip)
}
This work is licensed under the Apache 2.0 License
This work is licensed under the Apache 2.0 License
8. Get the solution code
To download the code for the finished codelab,
you can download the repository as a zip file, unzip it, and open it in Android
Studio.
This work is licensed under the Apache 2.0 License
9. Conclusion
Congratulations! You added custom tip functionality to your Tip Time App. Now your app lets users input a
custom tip percentage and round up the tip amount. Share your work on social media with #AndroidBasics!
This work is licensed under the Apache 2.0 License
Activity 5: Write automated text
What you'll learn
● What automated tests in Android do.
● Why automated tests are important.
● What a local test is and what it's used for.
● What an instrumentation test is and what it's used for.
● How to write local tests for Android code.
● How to write instrumentation tests for Android apps.
● How to run automated tests.
What you'll build
● A local test
● An instrumentation test
This work is licensed under the Apache 2.0 License
Why automated tests are important
At first, it might seem like you don't really need tests in your app, but testing is needed in apps of all
sizes and complexities.
To grow your codebase, you need to test existing functionality as you add new pieces, which is only
possible if you have existing tests. As your app grows, manual testing takes much more effort than
automated testing. Furthermore, once you start working on apps in production, testing becomes critical
when you have a large user base. For example, you must account for many different types of devices
running many different versions of Android.
Instrumentation tests
In the context of Android development, an instrumentation test is a UI test. Instrumentation tests let you test
parts of an app that depend on the Android, and its platform APIs and services.
Unlike local tests, UI tests launch an app or part of an app, simulate user interactions, and check whether the
app reacted appropriately. Throughout this course, UI tests are run on a physical device or emulator.
This work is licensed under the Apache 2.0 License
Conclusion
Tests are a critical component of software quality control. As you continue
to build Android apps, ensure that you write tests alongside your app
features to ensure that your apps work properly throughout the
development process.

More Related Content

Similar to -Kotlin Camp Unit2.pptx

Compose Camp Slide Session 1
Compose Camp Slide Session 1Compose Camp Slide Session 1
Compose Camp Slide Session 1
AkshatBajpai12
 
Compose_camp_Day_1.pptx
Compose_camp_Day_1.pptxCompose_camp_Day_1.pptx
Compose_camp_Day_1.pptx
GanpatParmar1
 
Compose Camp - Session1.pdf
Compose Camp - Session1.pdfCompose Camp - Session1.pdf
Compose Camp - Session1.pdf
GDSCAtharvaCollegeOf
 
Google Solution Challenge Android Awesomeness.pptx
Google Solution Challenge Android Awesomeness.pptxGoogle Solution Challenge Android Awesomeness.pptx
Google Solution Challenge Android Awesomeness.pptx
GoogleDeveloperStude22
 
Compose Camp #1.pptx
Compose  Camp #1.pptxCompose  Camp #1.pptx
Compose Camp #1.pptx
PratheeGuesylearn
 
Compose Camp Session 1.pdf
Compose Camp Session 1.pdfCompose Camp Session 1.pdf
Compose Camp Session 1.pdf
AbhishekRajoraB20CS0
 
Compose Camp - Unit 1 (1).pptx
Compose Camp - Unit 1 (1).pptxCompose Camp - Unit 1 (1).pptx
Compose Camp - Unit 1 (1).pptx
IshwariKulkarni6
 
Session 1 ppt.pptx
Session 1 ppt.pptxSession 1 ppt.pptx
Session 1 ppt.pptx
Sumit766160
 
Compose Camp
Compose Camp Compose Camp
Compose Camp
AthravMehta
 
Compose #1.pptx
Compose #1.pptxCompose #1.pptx
Compose #1.pptx
PratheeGuesylearn
 
Compose camp 2.pptx
Compose camp 2.pptxCompose camp 2.pptx
Compose camp 2.pptx
bcedsc
 
Compose Camp.pptx
Compose Camp.pptxCompose Camp.pptx
Compose Camp.pptx
YASHKUMARIIITDharwad
 
Google Compose Camp Session 3.pptx.pdf
Google Compose Camp Session 3.pptx.pdfGoogle Compose Camp Session 3.pptx.pdf
Google Compose Camp Session 3.pptx.pdf
Dhruv675089
 
compose 3.pptx
compose 3.pptxcompose 3.pptx
compose 3.pptx
SumirVats
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
mwillmer
 
Android Study Jam Prior Prog S-2
Android Study Jam Prior Prog S-2Android Study Jam Prior Prog S-2
Android Study Jam Prior Prog S-2
DSCIGDTUW
 
Compose Camp Slide Deck Template.pptx
Compose Camp Slide Deck Template.pptxCompose Camp Slide Deck Template.pptx
Compose Camp Slide Deck Template.pptx
GoogleDeveloperStude1
 
session4.pptx
session4.pptxsession4.pptx
session4.pptx
scienceTech11
 
session4.pptx
session4.pptxsession4.pptx
session4.pptx
RamshaAshraf12
 
Kotlin Fundamentals.pptx
Kotlin Fundamentals.pptxKotlin Fundamentals.pptx
Kotlin Fundamentals.pptx
PratheeGuesylearn
 

Similar to -Kotlin Camp Unit2.pptx (20)

Compose Camp Slide Session 1
Compose Camp Slide Session 1Compose Camp Slide Session 1
Compose Camp Slide Session 1
 
Compose_camp_Day_1.pptx
Compose_camp_Day_1.pptxCompose_camp_Day_1.pptx
Compose_camp_Day_1.pptx
 
Compose Camp - Session1.pdf
Compose Camp - Session1.pdfCompose Camp - Session1.pdf
Compose Camp - Session1.pdf
 
Google Solution Challenge Android Awesomeness.pptx
Google Solution Challenge Android Awesomeness.pptxGoogle Solution Challenge Android Awesomeness.pptx
Google Solution Challenge Android Awesomeness.pptx
 
Compose Camp #1.pptx
Compose  Camp #1.pptxCompose  Camp #1.pptx
Compose Camp #1.pptx
 
Compose Camp Session 1.pdf
Compose Camp Session 1.pdfCompose Camp Session 1.pdf
Compose Camp Session 1.pdf
 
Compose Camp - Unit 1 (1).pptx
Compose Camp - Unit 1 (1).pptxCompose Camp - Unit 1 (1).pptx
Compose Camp - Unit 1 (1).pptx
 
Session 1 ppt.pptx
Session 1 ppt.pptxSession 1 ppt.pptx
Session 1 ppt.pptx
 
Compose Camp
Compose Camp Compose Camp
Compose Camp
 
Compose #1.pptx
Compose #1.pptxCompose #1.pptx
Compose #1.pptx
 
Compose camp 2.pptx
Compose camp 2.pptxCompose camp 2.pptx
Compose camp 2.pptx
 
Compose Camp.pptx
Compose Camp.pptxCompose Camp.pptx
Compose Camp.pptx
 
Google Compose Camp Session 3.pptx.pdf
Google Compose Camp Session 3.pptx.pdfGoogle Compose Camp Session 3.pptx.pdf
Google Compose Camp Session 3.pptx.pdf
 
compose 3.pptx
compose 3.pptxcompose 3.pptx
compose 3.pptx
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
 
Android Study Jam Prior Prog S-2
Android Study Jam Prior Prog S-2Android Study Jam Prior Prog S-2
Android Study Jam Prior Prog S-2
 
Compose Camp Slide Deck Template.pptx
Compose Camp Slide Deck Template.pptxCompose Camp Slide Deck Template.pptx
Compose Camp Slide Deck Template.pptx
 
session4.pptx
session4.pptxsession4.pptx
session4.pptx
 
session4.pptx
session4.pptxsession4.pptx
session4.pptx
 
Kotlin Fundamentals.pptx
Kotlin Fundamentals.pptxKotlin Fundamentals.pptx
Kotlin Fundamentals.pptx
 

Recently uploaded

ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 

Recently uploaded (20)

ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 

-Kotlin Camp Unit2.pptx

  • 1. This work is licensed under the Apache 2.0 License
  • 2. This work is licensed under the Apache 2.0 License Learn fundamentals of Kotlin, object-oriented programming, and lambdas. Kotlin Fundamentals
  • 3. This work is licensed under the Apache 2.0 License ‘IF KEYWORD’ + ‘CONDITION YOU NEED TO EVALUATE’ BOOLEAN EXPRESSION Expressions combine values, variables, and operators that return a value. Boolean expressions return a boolean value. Use If/else statements to express conditions
  • 4.
  • 5. This work is licensed under the Apache 2.0 License Use a when statement for multiple branches In Kotlin, when you deal with multiple branches, you can use the when statement instead of the if/else statement because it improves readability, which refers to how easy it is for human readers, typically developers, to read the code. It's very important to consider readability when you write your code because it's likely that other developers need to review and modify your code throughout its lifetime
  • 6.
  • 7. This work is licensed under the Apache 2.0 License Use nullable variables 1)What is null? In Unit 1, you learned that when you declare a variable, you need to assign it a value immediately. For example, when you declare a favorite Actor variable, you may assign it a "Sandra Oh" string value immediately. However, what if you don't have a favorite actor? You might want to assign the variable a "Nobody" or "None" value. This isn't a good approach because your program interprets the favorite Actor variable to have a "Nobody" or "None" value rather than no value at all. In Kotlin, you can use null to indicate that there's no value associated with the variable.
  • 8.
  • 9. This work is licensed under the Apache 2.0 License Handle nullable variables Previously, you learned to use the . operator to access methods and properties of non-nullable variables. In this section, you learn how to use it to access methods and properties of nullable variables fun main() { var favoriteActor: String = "Sandra Oh" println(favoriteActor.length) }
  • 10. This work is licensed under the Apache 2.0 License Add a button to an app Learn how to respond to a button click in an Android app.
  • 11. This work is licensed under the Apache 2.0 License Define a class 1)A class definition starts with the class keyword, followed by a name and a set of curly braces. 2)The part of the syntax before the opening curly brace is also referred to as the class header. In the curly braces, you can specify properties and functions for the class.
  • 12. This work is licensed under the Apache 2.0 License Create an instance of a class 1)To use an object, you create the object and assign it to a variable, similar to how you define a variable. You use the val keyword to create an immutable variable and the var keyword for a mutable variable. 2)The val or var keyword is followed by the name of the variable, then an = assignment operator, then the instantiation of the class object. You can see the syntax in this diagram:
  • 13. This work is licensed under the Apache 2.0 License Define class methods Call a method on an object
  • 14. This work is licensed under the Apache 2.0 License Define class properties Properties are basically variables that are defined in the class body instead of the function body. This means that the syntax to define properties and variables are identical.
  • 15. ● Define a constructor 1. Default constructor 2. parameterized constructor Syntax :
  • 16. ● syntax to specify a visibility modifier for a property Visibility modifiers
  • 17. ● syntax to specify a visibility modifier for a method
  • 21. This work is licensed under the Apache 2.0 License . Create an interactive Dice Roller app
  • 22. ● Establish a baseline
  • 23. ● Create the layout infrastructure
  • 24.
  • 25. ● Create a vertical layout
  • 26. ● Add a button
  • 27. ● Add an image
  • 28. ● Add an Image composable
  • 29. ● Build the dice-roll logic
  • 30.
  • 31.
  • 32. ● Use the debugger in Android Studio
  • 33. ● Run the app with the debugger
  • 34. ● Practice: Click behavior App overview
  • 37. This work is licensed under the Apache 2.0 License COMPOSE CAMP SESSION 2
  • 38. This work is licensed under the Apache 2.0 License Pathway 3: Interact with UI and state
  • 39. Activity 1: Intro to state in Compose Activity 2:Calculate a custom tip Activity 3:Write automated tests Activity 4:Project: Create an Art Space app Create a tip calculator app that calculates the tip from user input in the app.
  • 40. This work is licensed under the Apache 2.0 License Activity 1: Intro to state in Compose What you'll learn ● How to think about state in a UI. ● How Compose uses state to display data. ● How to add a text box to your app. ● How to hoist a state. What you'll build ● A tip-calculator app called Tip Time that calculates a tip amount based on the service amount.
  • 41. This work is licensed under the Apache 2.0 License
  • 42. This work is licensed under the Apache 2.0 License
  • 43. This work is licensed under the Apache 2.0 License Create a project. <resources> <string name="app_name">Tip Time</string> <string name="calculate_tip">Calculate Tip</string> <string name="cost_of_service">Cost of Service</string> <string name="tip_amount">Tip amount: %s</string> </resources>
  • 44. This work is licensed under the Apache 2.0 License Add a screen title override fun onCreate(savedInstanceState: Bundle?) { //... setContent { TipTimeTheme { Surface( //... ) { TipTimeScreen() } } } }
  • 45. This work is licensed under the Apache 2.0 License @Preview(showBackground = true) @Composable fun DefaultPreview() { TipTimeTheme { TipTimeScreen() } } Column( modifier = Modifier.padding(32.dp), verticalArrangement = Arrangement.spacedBy(8.dp) ) {} import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding import androidx.compose.ui.unit.dp import androidx.compose.foundation.layout.Arrangement import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.sp import androidx.compose.ui.Alignment Text( text = stringResource(R.string.calculate_tip), fontSize = 24.sp, modifier = Modifier.align(Alignment.CenterHorizontally) )
  • 46. Add the TextField composable
  • 47. import androidx.compose.material.TextField @Composable fun TipTimeScreen() { Column( modifier = Modifier.padding(32.dp), verticalArrangement = Arrangement.spacedBy(8.dp) ) { Text( ... ) Spacer(Modifier.height(16.dp)) EditNumberField() } }
  • 48. This work is licensed under the Apache 2.0 License 6. Use state in Compose val amountInput = "0"
  • 49. This work is licensed under the Apache 2.0 License 7. The composition @Composable fun EditNumberField() { var amountInput = mutableStateOf("0") TextField( value = amountInput.value, onValueChange = { amountInput.value = it }, ) }
  • 50. This work is licensed under the Apache 2.0 License 8. Use remember function to save state Warning: This code may throw the error that you see in this image regarding the getValue() extension function: If so, manually add the getValue and setValue imports into the import block at the beginning of the file as you can see in this image:
  • 51. This work is licensed under the Apache 2.0 License Warning: This code may throw the error that you see in this image regarding the getValue() extension function: If so, manually add the getValue and setValue imports into the import block at the beginning of the file as you can see in this image:
  • 52. This work is licensed under the Apache 2.0 License @Composable fun EditNumberField() { var amountInput by remember { mutableStateOf("") } TextField( value = amountInput, onValueChange = { amountInput = it }, ) }
  • 53. This work is licensed under the Apache 2.0 License 9. State and recomposition in action
  • 54. This work is licensed under the Apache 2.0 License 10. Modify the appearance
  • 55. This work is licensed under the Apache 2.0 License @Composable fun EditNumberField() { var amountInput by remember { mutableStateOf("") } TextField( value = amountInput, onValueChange = { amountInput = it }, label = { Text(stringResource(R.string.cost_of_service)) }, modifier = Modifier.fillMaxWidth(), singleLine = true, keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number) ) }
  • 56. This work is licensed under the Apache 2.0 License
  • 57. This work is licensed under the Apache 2.0 License 11. Display the tip amount
  • 58. This work is licensed under the Apache 2.0 License private fun calculateTip( amount: Double, tipPercent: Double = 15.0 ): String { val tip = tipPercent / 100 * amount return NumberFormat.getCurrencyInstance().format(tip) }
  • 59. This work is licensed under the Apache 2.0 License @Composable fun EditNumberField() { var amountInput by remember { mutableStateOf("") } val amount = amountInput.toDoubleOrNull() ?: 0.0 val tip = calculateTip(amount) TextField( value = amountInput, onValueChange = { amountInput = it }, label = { Text(stringResource(R.string.cost_of_service)) }, modifier = Modifier.fillMaxWidth(), singleLine = true, keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number) ) }
  • 60. This work is licensed under the Apache 2.0 License Show the calculated tip amount
  • 61. This work is licensed under the Apache 2.0 License @Composable fun TipTimeScreen() { Column( //... ) { Text( text = stringResource(R.string.tip_amount, ""), modifier = Modifier.align(Alignment.CenterHorizontally), fontSize = 20.sp, fontWeight = FontWeight.Bold ) EditNumberField() Spacer(Modifier.height(24.dp)) } }
  • 62. This work is licensed under the Apache 2.0 License 12. State hosting Understand stateful versus stateless composables You should hoist the state when you need to: ● Share the state with multiple composable functions. ● Create a stateless composable that can be reused in your app.
  • 63. This work is licensed under the Apache 2.0 License @Composable fun TipTimeScreen() { var amountInput by remember { mutableStateOf("") } val amount = amountInput.toDoubleOrNull() ?: 0.0 val tip = calculateTip(amount) Column( modifier = Modifier.padding(32.dp), verticalArrangement = Arrangement.spacedBy(8.dp) ) { Text( text = stringResource(R.string.calculate_tip), fontSize = 24.sp, modifier = Modifier.align(Alignment.CenterHorizontally) ) Spacer(Modifier.height(16.dp)) EditNumberField(value = amountInput, onValueChange = { amountInput = it } ) Spacer(Modifier.height(24.dp)) Text( text = stringResource(R.string.tip_amount, tip), modifier = Modifier.align(Alignment.CenterHorizontally), fontSize = 20.sp, fontWeight = FontWeight.Bold ) } }
  • 64. This work is licensed under the Apache 2.0 License @Composable fun EditNumberField( value: String, onValueChange: (String) -> Unit ) { TextField( value = value, onValueChange = onValueChange, label = { Text(stringResource(R.string.cost_of_service)) }, modifier = Modifier.fillMaxWidth(), singleLine = true, keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number) ) }
  • 65. This work is licensed under the Apache 2.0 License
  • 66. This work is licensed under the Apache 2.0 License 13. Get the solution To download the code for the finished activity, you can download the repository as a zip file, unzip it, and open it in Android Studio.
  • 67. This work is licensed under the Apache 2.0 License Conclusion. Congratulations! You completed this codelab and learned how to use state in a Compose app! Summary ● State in an app is any value that can change over time. ● The Composition is a description of the UI built by Compose when it executes composables. Compose apps call composable functions to transform data into UI. ● Initial composition is a creation of the UI by Compose when it executes composable functions the first time. ● Recomposition is the process of running the same composables again to update the tree when their data changes. ● State hoisting is a pattern of moving state up to make a component stateless.
  • 68. This work is licensed under the Apache 2.0 License Activity 4: calculate a custom tip
  • 69. This work is licensed under the Apache 2.0 License What you'll learn ● How to add an action button to a virtual keyboard. ● How to set up keyboard actions. ● What a Switch composable is and how to use it. ● What the Layout Inspector is. What you'll build ● A Tip Time App that calculates tip amounts based on the user's inputted cost of service and tip percentage.
  • 70. This work is licensed under the Apache 2.0 License Starter app overview
  • 71. This work is licensed under the Apache 2.0 License 4. Add a tip-percentage text field @Composable fun EditNumberField( @StringRes label: Int, value: String, onValueChange: (String) -> Unit, modifier: Modifier = Modifier ) { TextField( //... label = { Text(stringResource(label)) }, //... ) }
  • 72. This work is licensed under the Apache 2.0 License EditNumberField( label = R.string.how_was_the_service, value = "", onValueChange = { } ) EditNumberField( label = R.string.how_was_the_service, value = tipInput, onValueChange = { tipInput = it } )
  • 73. This work is licensed under the Apache 2.0 License @Composable fun TipTimeScreen() { var amountInput by remember { mutableStateOf("") } var tipInput by remember { mutableStateOf("") } val tipPercent = tipInput.toDoubleOrNull() ?: 0.0 val amount = amountInput.toDoubleOrNull() ?: 0.0 val tip = calculateTip(amount, tipPercent) Column( modifier = Modifier.padding(32.dp), verticalArrangement = Arrangement.spacedBy(8.dp) ) { Text( text = stringResource(R.string.calculate_tip), fontSize = 24.sp, modifier = Modifier.align(Alignment.CenterHorizontally) ) Spacer(Modifier.height(16.dp)) EditNumberField( label = R.string.bill_amount, value = amountInput, onValueChange = { amountInput = it } ) EditNumberField( label = R.string.how_was_the_service, value = tipInput, onValueChange = { tipInput = it } ) Spacer(Modifier.height(24.dp)) Text( text = stringResource(R.string.tip_amount, tip), modifier = Modifier.align(Alignment.CenterHorizontally), fontSize = 20.sp, fontWeight = FontWeight.Bold ) } }
  • 74. This work is licensed under the Apache 2.0 License
  • 75. This work is licensed under the Apache 2.0 License 5. Set an action button @Composable fun EditNumberField( //... ) { TextField( //... keyboardOptions = KeyboardOptions.Default.copy( keyboardType = KeyboardType.Number, imeAction = ImeAction.Next ) ) }
  • 76. This work is licensed under the Apache 2.0 License
  • 77. This work is licensed under the Apache 2.0 License @Composable fun EditNumberField( @StringRes label: Int, keyboardOptions: KeyboardOptions, value: String, onValueChange: (String) -> Unit ){ TextField( //... keyboardOptions = keyboardOptions ) } EditNumberField( label = R.string.how_was_the_service, keyboardOptions = KeyboardOptions( keyboardType = KeyboardType.Number, imeAction = ImeAction.Done ), value = tipInput, onValueChange = { tipInput = it } )
  • 78. This work is licensed under the Apache 2.0 License
  • 79. This work is licensed under the Apache 2.0 License 7. Add a switch
  • 80. This work is licensed under the Apache 2.0 License @Composable fun RoundTheTipRow(roundUp: Boolean, onRoundUpChanged: (Boolean) -> Unit) { Row( modifier = Modifier .fillMaxWidth() .size(48.dp), verticalAlignment = Alignment.CenterVertically ) { Text(stringResource(R.string.round_up_tip)) Switch( modifier = Modifier .fillMaxWidth() .wrapContentWidth(Alignment.End), checked = roundUp, onCheckedChange = onRoundUpChanged, colors = SwitchDefaults.colors( uncheckedThumbColor = Color.DarkGray ) ) } }
  • 81. This work is licensed under the Apache 2.0 License 1. Thumb 2. Track
  • 82. This work is licensed under the Apache 2.0 License private fun calculateTip(amount: Double, tipPercent: Double = 15.0, roundUp: Boolean): String { var tip = tipPercent / 100 * amount if (roundUp) tip = kotlin.math.ceil(tip) return NumberFormat.getCurrencyInstance().format(tip) }
  • 83. This work is licensed under the Apache 2.0 License
  • 84. This work is licensed under the Apache 2.0 License 8. Get the solution code To download the code for the finished codelab, you can download the repository as a zip file, unzip it, and open it in Android Studio.
  • 85. This work is licensed under the Apache 2.0 License 9. Conclusion Congratulations! You added custom tip functionality to your Tip Time App. Now your app lets users input a custom tip percentage and round up the tip amount. Share your work on social media with #AndroidBasics!
  • 86. This work is licensed under the Apache 2.0 License Activity 5: Write automated text What you'll learn ● What automated tests in Android do. ● Why automated tests are important. ● What a local test is and what it's used for. ● What an instrumentation test is and what it's used for. ● How to write local tests for Android code. ● How to write instrumentation tests for Android apps. ● How to run automated tests. What you'll build ● A local test ● An instrumentation test
  • 87. This work is licensed under the Apache 2.0 License Why automated tests are important At first, it might seem like you don't really need tests in your app, but testing is needed in apps of all sizes and complexities. To grow your codebase, you need to test existing functionality as you add new pieces, which is only possible if you have existing tests. As your app grows, manual testing takes much more effort than automated testing. Furthermore, once you start working on apps in production, testing becomes critical when you have a large user base. For example, you must account for many different types of devices running many different versions of Android. Instrumentation tests In the context of Android development, an instrumentation test is a UI test. Instrumentation tests let you test parts of an app that depend on the Android, and its platform APIs and services. Unlike local tests, UI tests launch an app or part of an app, simulate user interactions, and check whether the app reacted appropriately. Throughout this course, UI tests are run on a physical device or emulator.
  • 88. This work is licensed under the Apache 2.0 License Conclusion Tests are a critical component of software quality control. As you continue to build Android apps, ensure that you write tests alongside your app features to ensure that your apps work properly throughout the development process.