3. Compose Camp is a hands-on introduction
to learning how you can build Android apps
with Jetpack Compose.
What is Compose Camp?
4. ● Computer & headphones
● Internet connection
● Android Studio
● Install Android studio in windows
● Install Android studio in macOS
Prerequisites
5. ●Build your first Android apps
●Set up Android Studio on your computer
●Learn the basics of the Kotlin programming language
●Learn Jetpack Compose
●Discover resources to continue learning
Compose Camp Learning Objectives
6. 1. Why are you here?
2. What are you goals?
3. How do you plan to achieve them?
14. TOPIC TIME
Introduction
Your first program in Kotlin
Create and use variables in Kotlin
Create and use functions in Kotlin
Break
Setting up Android Studio
Making your first project in Android
Studio Wrap Up
5:00 - 5:20
5:20 - 5:30
5:30 - 5:40
5:40 - 5:50
5:50 - 6:00
6:00 - 6:10
6:10 - 6:30
6:30 - 6:40
Session Overview
17. Program
Step by step instructions for
what the computer should do.
Output:
Hello, world!
fun main() {
println("Hello, world!") }
18. main Function
The main function is the entry
point, or starting point, of the
program.
Start here
Output:
Hello, world!
fun main() {
println("Hello, world!")
}
20.
My name is and I am years old.
Variables
Name value: Meghan
Age value: 28
Output:
Name value: Janet
Age value: 49
Output:
My name is Meghan and I
am 28 years old
My name is Janet and I
am 49 years old
Name
Age
21. Basic data types
Kotlin Data type What kind of data it can contain Example literal values
Int
Float
String
Double
Boolean
Text
Decimal number
Whole integer number
true or false. Use this data type when
there are only two possible values.
Decimal number (less precise than a Double).
Has an f or F at the end of the number.
“Add contact”
“Search”
32
-59873
2.0
-37123.9999
5.0f
-1630.209f
true
false
22. val keyword
var keyword
Use when you expect the variable value will
not change.
Example: name
Use when you expect the variable value can
change.
Example: age
Defining a variable
23. Defining a variable
All variables must have a name.
fun main() {
val name: String = "Meghan"
var age: Int = 28
}
24. Defining a variable
Data type is the type of
data that the variable holds.
fun main() {
val name: String = "Meghan"
var age: Int = 28
}
The initial value is the value that
is stored in the variable.
25. Functions
A function is a segment of a program that
performs a specific task.
You can have many functions in your program or
only a single one.
28. Defining a function
Functions need a set of parentheses
after the function name in order to
surround the function inputs.
fun displayIntroduction() {
}
29. Defining a function
The curly braces make up the
function body and contain the
instructions needed to
execute a task.
fun displayIntroduction( ) {
}
30. Putting it together
fun displayIntroduction() {
// We will fill this out!
}
Output:
Hi I’m Meghan and I am 28 years old
31. Putting it together
fun displayIntroduction() {
val name : String = "Meghan"
val age : Int = 28
println("Hi I'm $name and I am $age years old")
}
32. Putting it together
fun main() {
displayIntroduction()
}
fun displayIntroduction() {
val name : String = "Meghan"
val age : Int = 28
println("Hi I'm $name and I am $age years old") }
Output:
Hi I’m Meghan and I am 28 years old
33. This work is licensed under the Apache 2.0
License
Returning in a function
We can return an output from a
function as per its defined
output datatype.
fun displayIntroduction() : String {
return “HelloWorld”;
}
34. Parameters of a function
We can pass extra information
into a function via parameters
which are declared between the
parentheses.
fun add(n1 : Int, n2 : Int) {
return n1 + n2
}
35. Parameters of a function
These parameters can also have
default values.
fun add(n1 : Int = 0, n2 : Int = 0) {
return n1 + n2
}
36. Arguments of a function
While calling a function in another
function, the values we pass to
the parameters defined are
known as Arguments.
fun main() {
var a : Int = 2
var b : Int = 3
println(add(a, b))
}
37. Work on Unit 1, Pathway 1
Have a Question? Just ask
38. What’s coming next:
A live coding session in which you are going to build an exciting application:
Budget
Tracker
39. Share what you’ve
learned using
.#ComposeCamp
on social media
For a chance to be featured by
Android, submit your tips on
learning Compose to
goo.gle/compose-tips
40. See you at the next Compose Camp Session!
Optional resources to check out:
●
●
●
●
●
●
●
Official Android Developers Site: developer.android.com
Official Android Developers Blog (for announcements)
Android Developers Medium Blog (for more technical articles)
Android Developers YouTube channel
Follow @AndroidDev on Twitter
Follow @AndroidDev on LinkedIn
Subscribe to the Android Developer Newsletter