SlideShare a Scribd company logo
1 of 50
This work is licensed under the Apache 2.0 License
COMPOSE CAMP,
GDSC PATAN
WELCOME TO
SESSION ON BASICS
OF ANDROID
DEVELOPMENT
This work is licensed under the Apache 2.0 License
This work is licensed under the Apache 2.0 License
Ganpat Parmar
3rd Year Student
CSE Department
GEC, Patan
Camp Facilitator
This work is licensed under the Apache 2.0 License
Today’s Schedule
TOPIC
Basic Intro To Kotlin
Set-up Your Android Studio
Build Your First Android App
Basic Introduction to
Kotlin
This work is licensed under the Apache 2.0 License
This work is licensed under the Apache 2.0 License
What is Kotlin?
• Kotlin is a modern but already mature programming
language aimed to make developers happier.
• It's concise, safe, interoperable with Java and other
languages, and provides many ways to reuse code
between multiple platforms for productive
programming.
This work is licensed under the Apache 2.0 License
What’s Kotlin is for?
Multiplatform
Sharing code between
mobile platforms is one of
the major Kotlin
Multiplatform use cases.
Server Side
Kotlin is a great fit for
developing server-side
applications. It allows
you to write concise and
expressive code.
JavaScript
Kotlin/JS provides the
ability to transpile your
Kotlin code, the Kotlin
standard library, and any
compatible dependencies
to JavaScript
Data Science
From building data
pipelines to
productionizing machine
learning models, Kotlin
can be a great choice for
working with data
This work is licensed under the Apache 2.0 License
Kotlin for Android
• Less code combined with greater readability
• Mature language and environment
• Kotlin support in Android Jetpack and other
libraries.
• Interoperability with Java
• Support for multiplatform development
• Code safety
• Easy learning
• Big community
This work is licensed under the Apache 2.0 License
Lets get handy
with Kotlin 
This work is licensed under the Apache 2.0 License
● Kotlin Compiler
● Compiler v/s Interpreter
● main() Function
Our First Program in
Kotlin
Output
This work is licensed under the Apache 2.0 License
Parts of a Function
● Define v/s call a Function
● Define a Function
1. fun keyword
2. Name (camelCase)
3. Inputs
4. body (Multiple Lines;)
fun ( ) {
}
name inputs
body
This work is licensed under the Apache 2.0 License
Kotlin Style Guide
1. Function names should be in camel case and should be
verb or verb phase.
2. Each statement should be on its own line.
3. The opening curly braces should appear at the end of
the line where function begins.
4. There should be space before opening curly brace.
5. Indent by 4 spaces.
6. Vertically align.
space
Opening
braces
indent
Variables Oh!
Dear, container's
This work is licensed under the Apache 2.0 License
This work is licensed under the Apache 2.0 License
Container and Label Relationship
name
value
This work is licensed under the Apache 2.0 License
Data Types
Kotlin Data type What kind of data it can
contain
Range Example
String Text String of any length “Hello World”,
“b”, “A”
Int Whole Integer Number -2147483648 to 2147483647 28, 2001, -8925
Double Decimal Number -1.79769313486231E308 to -
4.94065645841247E-324 (for -ve)
4.94065645841247E-324 to
1.79769313486232E308 (for +ve)
4283.01413
-256.3241
Float Decimal number that is less precise
then decimal number
4.94065645841247E-324 to
1.79769313486232E308
1.98
3.14
-54.89
Boolean Use when there are only two possible
values.
True or False true
false
This work is licensed under the Apache 2.0 License
Define and Use Variables
● Declare a variable (a)
name
Val : data type = Initial value
Val count : Int = 2
Assignment
operator
This work is licensed under the Apache 2.0 License
Define and Use Variables
● Declare a variable (b)
name
Var = Initial value
Var count = 2
This work is licensed under the Apache 2.0 License
Difference b/w val and var
val keyword:-
Whenever we declare a variable with val keyword it
means that it’s a constant. Its value can not be
changed throughout the program.
var keyword:-
When we declare a variable with var keyword it
means that it is not a constant and we can reassign
new value to that variable
This work is licensed under the Apache 2.0 License
Basic Math operations with Integers
Basic calculations :-
 Define an integers variable for unread
un-read emails in your inbox. And
initialize it with value such as 50.
 Define an integers variable for unread
read emails in your inbox. And
initialize it with value such as 100.
 Then print total number of emails in your inbox by adding the two integers numbers together.
 Run the program and it should display the total numbers of messages in the inbox.
This work is licensed under the Apache 2.0 License
Update Variables
numberOfItems
30
5
This work is licensed under the Apache 2.0 License
Explore Other Data Types
This work is licensed under the Apache 2.0 License
Explore Other Data Types
This work is licensed under the Apache 2.0 License
Explore Other Data Types
This work is licensed under the Apache 2.0 License
Enhance the readability of Your Code
// This is Comment
/*
* This is a very long comment that can
* take up multiple lines.
*/
 Single Line Comment
 Multi Line Comment
This work is licensed under the Apache 2.0 License
Continue…
This work is licensed under the Apache 2.0 License
Conclusion
 A variable is a container for a single piece of data.
 You must declare a variable first before you use it.
 Use the val keyword to define a variable that is read-only where the value cannot change once it's
been assigned.
 Use the var keyword to define a variable that is mutable or changeable.
 In Kotlin, it's preferred to use val over var when possible.
 To declare a variable, start with the val or var keyword. Then specify the variable name, data type,
and initial value. For example: val count: Int = 2.
This work is licensed under the Apache 2.0 License
Continue..
 With type inference, omit the data type in the variable declaration if an initial value is provided.
 Some common basic Kotlin data types include: Int, String, Boolean, Float, and Double.
 Use the assignment operator (=) to assign a value to a variable either during declaration of the
variable or updating the variable.
 You can only update a variable that has been declared as a mutable variable (with var).
 Use the increment operator (++) or decrement operator (--) to increase or decrease the value of
an integer variable by 1, respectively.
 Use the + symbol to concatenate strings together. You can also concatenate variables of other data
types like Int and Boolean to Strings.
Functions
This work is licensed under the Apache 2.0 License
This work is licensed under the Apache 2.0 License
Define and call a Function
fun ( ) {
}
name inputs
body
This work is licensed under the Apache 2.0 License
Can Function Return Something ?
fun ( ) : {
}
name inputs
body
Return type
Return statement
This work is licensed under the Apache 2.0 License
Function Returning String
This work is licensed under the Apache 2.0 License
Function With Multiple Arguments
This work is licensed under the Apache 2.0 License
Function With Default Arguments
This work is licensed under the Apache 2.0 License
Conclusion
•Functions are defined with the fun keyword and contain reusable pieces of code.
•Functions help make larger programs easier to maintain and prevent the unnecessary repetition of code.
•Functions can return a value that you can store in a variable for later use.
•Functions can take parameters, which are variables available inside a function body.
•Arguments are the values that you pass in when you call a function
•You can name arguments when you call a function. When you use named arguments, you can reorder the arguments
without affecting the output.
•You can specify a default argument that lets you omit the argument when you call a function.
Practice Problems
This work is licensed under the Apache 2.0 License
This work is licensed under the Apache 2.0 License
Problem – 1 (print messages)
• Can you write a main() function that prints these messages on four separate lines?
 Use the val keyword when the value doesn't change.
 Use the var keyword when the value can change.
 When you define a function, you define the parameters that can be passed to it.
 When you call a function, you pass arguments for the parameters.
This work is licensed under the Apache 2.0 License
Problem – 2 (fix compile error)
fun main() {
println("New chat message from a friend'}
}
1. Can you figure out the root cause of the compile errors in this program and fix them?
2. Does the code use appropriate symbols to indicate the open and close of the string and function
argument?
This work is licensed under the Apache 2.0 License
Problem – 3 (String Templaets)
fun main() {
val discountPercentage: Int = 0
val offer: String = ""
val item = "Google Chromecast"
discountPercentage = 20
offer = "Sale - Up to $discountPercentage% discount on $item! Hurry up!"
println(offer)
}
1) Can you figure out the root cause of the errors and fix them?
2) Can you determine the output of this program before you run the code in Kotlin Playground?
This work is licensed under the Apache 2.0 License
Problem – 4 (String Concatenation)
Can you guess the output ?
fun main() {
val numberOfAdults = "20"
val numberOfKids = "30"
val total = numberOfAdults + numberOfKids
println("The total party size is: $total")
}
This work is licensed under the Apache 2.0 License
Problem – 5 (Message formatting)
1) Can you figure out the output of this code before you run it in Kotlin Playground?
2) When you run the code in Kotlin Playground, does it print the output that you expected?
fun main() {
val baseSalary = 5000
val bonusAmount = 1000
val totalSalary = "$baseSalary + $bonusAmount"
println("Congratulations for your bonus! You will receive a
total of $totalSalary(additional bonus).")
}
This work is licensed under the Apache 2.0 License
Problem – 6 (Implement basic math operations)
fun main() {
val firstNumber = 10
val secondNumber = 5
val thirdNumber = 8
val result = add(firstNumber, secondNumber)
val anotherResult = add(firstNumber, thirdNumber)
println("$firstNumber + $secondNumber = $result")
println("$firstNumber + $thirdNumber = $anotherResult")
}
// Define add() function below this line
Can you guess the output ?
This work is licensed under the Apache 2.0 License
Problem – 7
Can you guess the Reason ?
?
This work is licensed under the Apache 2.0 License
Introduction to
Jetpack Compose
This work is licensed under the Apache 2.0 License
Let’s start Making Our First Android
App Using Jetpack Compose
Design Pane in Android Studio
Add a new Text element
Change Font size
Add another text element
Arrange text element in column and row
Display on the device
This work is licensed under the Apache 2.0 License
Add Image Composable to Our App
Add Box Layout, Row and Column layout
Position and Scale the Image Composable
Align text and add padding
Arrange Adopt good scale Practice
Display on the device
This work is licensed under the Apache 2.0 License
Let’s Practice Some of the Composable that we
have learnt
Text Composable
Column Composable
Row Composable
Image Composable
This work is licensed under the Apache 2.0 License
Let’s Practice Some of the Composable that we
have learnt
This work is licensed under the Apache 2.0 License
Let’s Practice Some of the Composable that we
have learnt
This work is licensed under the Apache 2.0 License
Let’s Practice Some of the Composable that we
have learnt
This work is licensed under the Apache 2.0 License
THANK
YOU
This work is licensed under the Apache 2.0 License

More Related Content

What's hot

Scaling Teams, Processes and Architectures
Scaling Teams, Processes and ArchitecturesScaling Teams, Processes and Architectures
Scaling Teams, Processes and ArchitecturesLorenzo Alberton
 
What is Material UI?
What is Material UI?What is Material UI?
What is Material UI?Flatlogic
 
Let's discover React and Redux with TypeScript
Let's discover React and Redux with TypeScriptLet's discover React and Redux with TypeScript
Let's discover React and Redux with TypeScriptMathieu Savy
 
Project Launch Meeting PowerPoint Presentation Slides
Project Launch Meeting PowerPoint Presentation SlidesProject Launch Meeting PowerPoint Presentation Slides
Project Launch Meeting PowerPoint Presentation SlidesSlideTeam
 
Android Jetpack
Android Jetpack Android Jetpack
Android Jetpack Tudor Sirbu
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJSKnoldus Inc.
 
Creating A Product Backlog
Creating A Product BacklogCreating A Product Backlog
Creating A Product BacklogRussell Pannone
 
An introduction to Agile & Scrum
An introduction to Agile & ScrumAn introduction to Agile & Scrum
An introduction to Agile & ScrumMahdi Taghizadeh
 
Structural Design pattern - Adapter
Structural Design pattern - AdapterStructural Design pattern - Adapter
Structural Design pattern - AdapterManoj Kumar
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShellSalaudeen Rajack
 
Enviar mensagem via console no windows server 2012
Enviar mensagem via console no windows server 2012Enviar mensagem via console no windows server 2012
Enviar mensagem via console no windows server 2012jcis_udo
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVCDzmitry Naskou
 

What's hot (15)

Scaling Teams, Processes and Architectures
Scaling Teams, Processes and ArchitecturesScaling Teams, Processes and Architectures
Scaling Teams, Processes and Architectures
 
What is Material UI?
What is Material UI?What is Material UI?
What is Material UI?
 
Let's discover React and Redux with TypeScript
Let's discover React and Redux with TypeScriptLet's discover React and Redux with TypeScript
Let's discover React and Redux with TypeScript
 
Project Launch Meeting PowerPoint Presentation Slides
Project Launch Meeting PowerPoint Presentation SlidesProject Launch Meeting PowerPoint Presentation Slides
Project Launch Meeting PowerPoint Presentation Slides
 
Android Jetpack
Android Jetpack Android Jetpack
Android Jetpack
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
android studio
 android studio android studio
android studio
 
Creating A Product Backlog
Creating A Product BacklogCreating A Product Backlog
Creating A Product Backlog
 
An introduction to Agile & Scrum
An introduction to Agile & ScrumAn introduction to Agile & Scrum
An introduction to Agile & Scrum
 
Structural Design pattern - Adapter
Structural Design pattern - AdapterStructural Design pattern - Adapter
Structural Design pattern - Adapter
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
TP2 RMI
TP2 RMITP2 RMI
TP2 RMI
 
Scrumban
ScrumbanScrumban
Scrumban
 
Enviar mensagem via console no windows server 2012
Enviar mensagem via console no windows server 2012Enviar mensagem via console no windows server 2012
Enviar mensagem via console no windows server 2012
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVC
 

Similar to Compose_camp_Day_1.pptx

Compose Camp Slide Deck Template.pptx
Compose Camp Slide Deck Template.pptxCompose Camp Slide Deck Template.pptx
Compose Camp Slide Deck Template.pptxGoogleDeveloperStude1
 
Compose Camp#2 - Kotlin Basics.pptx
Compose Camp#2 - Kotlin Basics.pptxCompose Camp#2 - Kotlin Basics.pptx
Compose Camp#2 - Kotlin Basics.pptxSumirVats
 
Compose Camp - Unit 1 (1).pptx
Compose Camp - Unit 1 (1).pptxCompose Camp - Unit 1 (1).pptx
Compose Camp - Unit 1 (1).pptxIshwariKulkarni6
 
-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptx-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptxRishiGandhi19
 
Compose camp 2.pptx
Compose camp 2.pptxCompose camp 2.pptx
Compose camp 2.pptxbcedsc
 
GDSC_day_1.pptx
GDSC_day_1.pptxGDSC_day_1.pptx
GDSC_day_1.pptxGDSCICOER
 
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdf
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdfAndroid Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdf
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdfShivamShrey1
 
Compose Camp Day 1.pdf
Compose Camp Day 1.pdfCompose Camp Day 1.pdf
Compose Camp Day 1.pdfShivamShrey1
 
Session-1 edited.pptx
Session-1 edited.pptxSession-1 edited.pptx
Session-1 edited.pptxscienceTech11
 

Similar to Compose_camp_Day_1.pptx (20)

Compose Camp - Session1.pdf
Compose Camp - Session1.pdfCompose Camp - Session1.pdf
Compose Camp - Session1.pdf
 
Compose #1.pptx
Compose #1.pptxCompose #1.pptx
Compose #1.pptx
 
Compose Camp Slide Deck Template.pptx
Compose Camp Slide Deck Template.pptxCompose Camp Slide Deck Template.pptx
Compose Camp Slide Deck Template.pptx
 
Copy of kotlin.pptx
Copy of kotlin.pptxCopy of kotlin.pptx
Copy of kotlin.pptx
 
Kotlin Fundamentals.pptx
Kotlin Fundamentals.pptxKotlin Fundamentals.pptx
Kotlin Fundamentals.pptx
 
Compose Camp#2 - Kotlin Basics.pptx
Compose Camp#2 - Kotlin Basics.pptxCompose Camp#2 - Kotlin Basics.pptx
Compose Camp#2 - Kotlin Basics.pptx
 
day1.docx
day1.docxday1.docx
day1.docx
 
Compose Camp - Unit 1 (1).pptx
Compose Camp - Unit 1 (1).pptxCompose Camp - Unit 1 (1).pptx
Compose Camp - Unit 1 (1).pptx
 
Compose Camp Session 1.pdf
Compose Camp Session 1.pdfCompose Camp Session 1.pdf
Compose Camp Session 1.pdf
 
-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptx-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptx
 
-Kotlin Camp Unit2.pptx
-Kotlin Camp Unit2.pptx-Kotlin Camp Unit2.pptx
-Kotlin Camp Unit2.pptx
 
Compose Camp
Compose Camp Compose Camp
Compose Camp
 
Session-1.pptx
Session-1.pptxSession-1.pptx
Session-1.pptx
 
Compose camp 2.pptx
Compose camp 2.pptxCompose camp 2.pptx
Compose camp 2.pptx
 
GDSC_day_1.pptx
GDSC_day_1.pptxGDSC_day_1.pptx
GDSC_day_1.pptx
 
Compose Camp.pptx
Compose Camp.pptxCompose Camp.pptx
Compose Camp.pptx
 
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdf
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdfAndroid Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdf
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdf
 
Compose Camp Day 1.pdf
Compose Camp Day 1.pdfCompose Camp Day 1.pdf
Compose Camp Day 1.pdf
 
Session-1 edited.pptx
Session-1 edited.pptxSession-1 edited.pptx
Session-1 edited.pptx
 
topic_perlcgi
topic_perlcgitopic_perlcgi
topic_perlcgi
 

Recently uploaded

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 

Compose_camp_Day_1.pptx

  • 1. This work is licensed under the Apache 2.0 License COMPOSE CAMP, GDSC PATAN
  • 2. WELCOME TO SESSION ON BASICS OF ANDROID DEVELOPMENT This work is licensed under the Apache 2.0 License
  • 3. This work is licensed under the Apache 2.0 License Ganpat Parmar 3rd Year Student CSE Department GEC, Patan Camp Facilitator
  • 4. This work is licensed under the Apache 2.0 License Today’s Schedule TOPIC Basic Intro To Kotlin Set-up Your Android Studio Build Your First Android App
  • 5. Basic Introduction to Kotlin This work is licensed under the Apache 2.0 License
  • 6. This work is licensed under the Apache 2.0 License What is Kotlin? • Kotlin is a modern but already mature programming language aimed to make developers happier. • It's concise, safe, interoperable with Java and other languages, and provides many ways to reuse code between multiple platforms for productive programming.
  • 7. This work is licensed under the Apache 2.0 License What’s Kotlin is for? Multiplatform Sharing code between mobile platforms is one of the major Kotlin Multiplatform use cases. Server Side Kotlin is a great fit for developing server-side applications. It allows you to write concise and expressive code. JavaScript Kotlin/JS provides the ability to transpile your Kotlin code, the Kotlin standard library, and any compatible dependencies to JavaScript Data Science From building data pipelines to productionizing machine learning models, Kotlin can be a great choice for working with data
  • 8. This work is licensed under the Apache 2.0 License Kotlin for Android • Less code combined with greater readability • Mature language and environment • Kotlin support in Android Jetpack and other libraries. • Interoperability with Java • Support for multiplatform development • Code safety • Easy learning • Big community
  • 9. This work is licensed under the Apache 2.0 License Lets get handy with Kotlin 
  • 10. This work is licensed under the Apache 2.0 License ● Kotlin Compiler ● Compiler v/s Interpreter ● main() Function Our First Program in Kotlin Output
  • 11. This work is licensed under the Apache 2.0 License Parts of a Function ● Define v/s call a Function ● Define a Function 1. fun keyword 2. Name (camelCase) 3. Inputs 4. body (Multiple Lines;) fun ( ) { } name inputs body
  • 12. This work is licensed under the Apache 2.0 License Kotlin Style Guide 1. Function names should be in camel case and should be verb or verb phase. 2. Each statement should be on its own line. 3. The opening curly braces should appear at the end of the line where function begins. 4. There should be space before opening curly brace. 5. Indent by 4 spaces. 6. Vertically align. space Opening braces indent
  • 13. Variables Oh! Dear, container's This work is licensed under the Apache 2.0 License
  • 14. This work is licensed under the Apache 2.0 License Container and Label Relationship name value
  • 15. This work is licensed under the Apache 2.0 License Data Types Kotlin Data type What kind of data it can contain Range Example String Text String of any length “Hello World”, “b”, “A” Int Whole Integer Number -2147483648 to 2147483647 28, 2001, -8925 Double Decimal Number -1.79769313486231E308 to - 4.94065645841247E-324 (for -ve) 4.94065645841247E-324 to 1.79769313486232E308 (for +ve) 4283.01413 -256.3241 Float Decimal number that is less precise then decimal number 4.94065645841247E-324 to 1.79769313486232E308 1.98 3.14 -54.89 Boolean Use when there are only two possible values. True or False true false
  • 16. This work is licensed under the Apache 2.0 License Define and Use Variables ● Declare a variable (a) name Val : data type = Initial value Val count : Int = 2 Assignment operator
  • 17. This work is licensed under the Apache 2.0 License Define and Use Variables ● Declare a variable (b) name Var = Initial value Var count = 2
  • 18. This work is licensed under the Apache 2.0 License Difference b/w val and var val keyword:- Whenever we declare a variable with val keyword it means that it’s a constant. Its value can not be changed throughout the program. var keyword:- When we declare a variable with var keyword it means that it is not a constant and we can reassign new value to that variable
  • 19. This work is licensed under the Apache 2.0 License Basic Math operations with Integers Basic calculations :-  Define an integers variable for unread un-read emails in your inbox. And initialize it with value such as 50.  Define an integers variable for unread read emails in your inbox. And initialize it with value such as 100.  Then print total number of emails in your inbox by adding the two integers numbers together.  Run the program and it should display the total numbers of messages in the inbox.
  • 20. This work is licensed under the Apache 2.0 License Update Variables numberOfItems 30 5
  • 21. This work is licensed under the Apache 2.0 License Explore Other Data Types
  • 22. This work is licensed under the Apache 2.0 License Explore Other Data Types
  • 23. This work is licensed under the Apache 2.0 License Explore Other Data Types
  • 24. This work is licensed under the Apache 2.0 License Enhance the readability of Your Code // This is Comment /* * This is a very long comment that can * take up multiple lines. */  Single Line Comment  Multi Line Comment
  • 25. This work is licensed under the Apache 2.0 License Continue…
  • 26. This work is licensed under the Apache 2.0 License Conclusion  A variable is a container for a single piece of data.  You must declare a variable first before you use it.  Use the val keyword to define a variable that is read-only where the value cannot change once it's been assigned.  Use the var keyword to define a variable that is mutable or changeable.  In Kotlin, it's preferred to use val over var when possible.  To declare a variable, start with the val or var keyword. Then specify the variable name, data type, and initial value. For example: val count: Int = 2.
  • 27. This work is licensed under the Apache 2.0 License Continue..  With type inference, omit the data type in the variable declaration if an initial value is provided.  Some common basic Kotlin data types include: Int, String, Boolean, Float, and Double.  Use the assignment operator (=) to assign a value to a variable either during declaration of the variable or updating the variable.  You can only update a variable that has been declared as a mutable variable (with var).  Use the increment operator (++) or decrement operator (--) to increase or decrease the value of an integer variable by 1, respectively.  Use the + symbol to concatenate strings together. You can also concatenate variables of other data types like Int and Boolean to Strings.
  • 28. Functions This work is licensed under the Apache 2.0 License
  • 29. This work is licensed under the Apache 2.0 License Define and call a Function fun ( ) { } name inputs body
  • 30. This work is licensed under the Apache 2.0 License Can Function Return Something ? fun ( ) : { } name inputs body Return type Return statement
  • 31. This work is licensed under the Apache 2.0 License Function Returning String
  • 32. This work is licensed under the Apache 2.0 License Function With Multiple Arguments
  • 33. This work is licensed under the Apache 2.0 License Function With Default Arguments
  • 34. This work is licensed under the Apache 2.0 License Conclusion •Functions are defined with the fun keyword and contain reusable pieces of code. •Functions help make larger programs easier to maintain and prevent the unnecessary repetition of code. •Functions can return a value that you can store in a variable for later use. •Functions can take parameters, which are variables available inside a function body. •Arguments are the values that you pass in when you call a function •You can name arguments when you call a function. When you use named arguments, you can reorder the arguments without affecting the output. •You can specify a default argument that lets you omit the argument when you call a function.
  • 35. Practice Problems This work is licensed under the Apache 2.0 License
  • 36. This work is licensed under the Apache 2.0 License Problem – 1 (print messages) • Can you write a main() function that prints these messages on four separate lines?  Use the val keyword when the value doesn't change.  Use the var keyword when the value can change.  When you define a function, you define the parameters that can be passed to it.  When you call a function, you pass arguments for the parameters.
  • 37. This work is licensed under the Apache 2.0 License Problem – 2 (fix compile error) fun main() { println("New chat message from a friend'} } 1. Can you figure out the root cause of the compile errors in this program and fix them? 2. Does the code use appropriate symbols to indicate the open and close of the string and function argument?
  • 38. This work is licensed under the Apache 2.0 License Problem – 3 (String Templaets) fun main() { val discountPercentage: Int = 0 val offer: String = "" val item = "Google Chromecast" discountPercentage = 20 offer = "Sale - Up to $discountPercentage% discount on $item! Hurry up!" println(offer) } 1) Can you figure out the root cause of the errors and fix them? 2) Can you determine the output of this program before you run the code in Kotlin Playground?
  • 39. This work is licensed under the Apache 2.0 License Problem – 4 (String Concatenation) Can you guess the output ? fun main() { val numberOfAdults = "20" val numberOfKids = "30" val total = numberOfAdults + numberOfKids println("The total party size is: $total") }
  • 40. This work is licensed under the Apache 2.0 License Problem – 5 (Message formatting) 1) Can you figure out the output of this code before you run it in Kotlin Playground? 2) When you run the code in Kotlin Playground, does it print the output that you expected? fun main() { val baseSalary = 5000 val bonusAmount = 1000 val totalSalary = "$baseSalary + $bonusAmount" println("Congratulations for your bonus! You will receive a total of $totalSalary(additional bonus).") }
  • 41. This work is licensed under the Apache 2.0 License Problem – 6 (Implement basic math operations) fun main() { val firstNumber = 10 val secondNumber = 5 val thirdNumber = 8 val result = add(firstNumber, secondNumber) val anotherResult = add(firstNumber, thirdNumber) println("$firstNumber + $secondNumber = $result") println("$firstNumber + $thirdNumber = $anotherResult") } // Define add() function below this line Can you guess the output ?
  • 42. This work is licensed under the Apache 2.0 License Problem – 7 Can you guess the Reason ? ?
  • 43. This work is licensed under the Apache 2.0 License Introduction to Jetpack Compose
  • 44. This work is licensed under the Apache 2.0 License Let’s start Making Our First Android App Using Jetpack Compose Design Pane in Android Studio Add a new Text element Change Font size Add another text element Arrange text element in column and row Display on the device
  • 45. This work is licensed under the Apache 2.0 License Add Image Composable to Our App Add Box Layout, Row and Column layout Position and Scale the Image Composable Align text and add padding Arrange Adopt good scale Practice Display on the device
  • 46. This work is licensed under the Apache 2.0 License Let’s Practice Some of the Composable that we have learnt Text Composable Column Composable Row Composable Image Composable
  • 47. This work is licensed under the Apache 2.0 License Let’s Practice Some of the Composable that we have learnt
  • 48. This work is licensed under the Apache 2.0 License Let’s Practice Some of the Composable that we have learnt
  • 49. This work is licensed under the Apache 2.0 License Let’s Practice Some of the Composable that we have learnt
  • 50. This work is licensed under the Apache 2.0 License THANK YOU This work is licensed under the Apache 2.0 License

Editor's Notes

  1. Count = Count + 1
  2. Count = Count + 1
  3. Count = Count + 1
  4. Count = Count + 1
  5. Count = Count + 1
  6. Count = Count + 1
  7. Count = Count + 1
  8. Count = Count + 1
  9. Named Arguments
  10. Count = Count + 1
  11. Count = Count + 1
  12. Count = Count + 1