3. What is Kotlin ?
Kotlin is is a cross-platform, statically typed, general-
purpose programming language
OOPS + FP
It was introduced by JetBrains in 2011.
At Google I/O 2017, Google announced first-class
support for Kotlin on Android and announced Kotlin as
an official language for android development
4. History of Kotlin
2010 Project Started
2016 Kotlin 1.0
2017 Officially Supported Language in
Android
2019 Android Becomes Kotlin first
2020 Kotlin 1.4 Preview
5. Why Kotlin ?
Kotlin is designed to interoperate fully with Java,
and the JVM version of kotlin's standard library
depends on the Java class library
Google made Kotlin as first preference for developing
apps
30% less code as compared to Java
Time spent on reviews and maintenance is less
60% professional Android developers use Kotlin
6.
7. Kotlin is an programming language that combines
object-oriented programming and functional features
into a unique platform
main() function - Entry point of the kotlin application
function declaration -- > fun keyword
main() function
8. Variables in
Kotlin
Kotlin provides 2 types of Variables
var - mutable value
val - immutable value
Keyword
Variable
name
Data Type
Value of the variable
9. Control Flow
if....else Statements
The if/else statement executes a block of code if a
specified condition is true. If the condition is false,
another block of code can be executed
10. Control Flow
When Statement
Kotlin when can be used either as an expression or as a statement, simply like
a switch statement in Java. If it is used as an expression, the value of the first
matching branch becomes the value of the overall expression.
11. Loops
for Loop
a for-loop is a control flow statement for specifying iteration, which allows
code to be executed repeatedly
13. Loops
do...while Loop
The do..while is similar to the while loop with a difference that the this loop
will execute the code block once, before checking if the condition is true, then
it will repeat the loop as long as the condition is true.
14. Functions
Kotlin is a statically typed language, hence,
functions play a great role in it.
A function is a block of code which is written
to perform a particular task.
Built - in functions
Kotlin provides a number of built-in functions, we
have used a number of buil-in functions in our
examples. For example print() and println() are the
most commonly used built-in function which we use
to print an output to the screen.
15. What is
Android Studio ?
Android Studio is the official Integrated Development
Environment (IDE) for android application
development.
It is built on JetBrains' IntelliJ IDEA software and
designed specifically for Android development.
It is available for download on Windows, macOS and
Linux based operating systems
16. Features of Android
Studio
Gradle-based build support
Template-based wizards to create common Android
designs and components
A rich layout editor that allows users to drag-and-drop UI
components, option to preview layouts on multiple screen
configurations[18]
Built-in support for Google Cloud Platform, enabling
integration with Firebase Cloud Messaging
Android Virtual Device (Emulator) to run and debug apps
in the Android studio.
17. Steps to Install
Android Studio
Prerequisites :
-> 64-bit Operating System(for Windows and linux)
-> Java installed on your system
-> To check
Go to command prompt and type java -version
28. Menu Bar
Tool Bar
Project Window
Code Editor Window
MAIN WINDOW
OVERVIEW
New – Creates new
Android Application
Open – Opens existing
Android Application
Open Recent – Shows the
list of recently opened
projects and clicking on
one of them would open
the project.
ANDROID FILE MENU
Android Studio
Walk through
In addition to Text Editor,
Activity Layout files could be
edited using XML Design
Editor. The UI elements could
be drag and dropped to the
Layout at center.
ANDROID XML DESIGN
EDITOR
ANDROID TOOL BAR
29.
30.
31.
32.
33.
34. App components
Activities
Services
Broadcast receivers
Content providers
App components are the essential building blocks of
an Android app. Each component is an entry point
through which the system or a user can enter your
app.
There are four different types of app components:
35. Activity
An Activity represents a single screen with a user
interface
It deals with the UI and the user interactions to the
screen. In other words, it is a User Interface that
contains activities. These can be one or more
depending upon the App. It starts when the
application is launched.
In an android app at least one activity is always
present which is known as MainActivity.
37. XML
XML - EXTENSIBLE MARKUP LANGUAGE
XML is a markup language much like HTML used to
describe data. It is derived from Standard
Generalized Markup Language(SMGL).
XML tags define the data and used to store and
organize data. It’s easily scalable and simple to
develop. In Android, the XML is used to implement UI-
related data, and it’s a lightweight markup language
that doesn’t make layout heavy. XML only contains
tags, while implementing they need to be just
invoked.
40. In Android Studio you can run your code either in an
physical device or in an android emulator
For running on physical device :
-> Enable Developer options in your android device
-> Enable USB debugging in developer options
-> Connect your phone to your laptop/desktop via a
USB cable
-> Run your code in your device
Run your code
41. The Android Emulator simulates Android devices on
your computer so that you can test your application
on a variety of devices and Android API levels without
needing to have each physical device.
The emulator provides almost all of the capabilities
of a real Android device. You can simulate incoming
phone calls and text messages, specify the location
of the device, simulate different network speeds,
simulate rotation and other hardware sensors,
access the Google Play Store, and much more.
Android Emulator
42. Create and manage virtual devices
Select Tools > AVD Manager.
Click AVD Manager in the toolbar.
An Android Virtual Device (AVD) is a
configuration that defines the
characteristics of an Android phone,
tablet, Wear OS, Android TV, or
Automotive OS device that you want to
simulate in the Android Emulator. The
AVD Manager is an interface you can
launch from Android Studio that helps
you create and manage AVDs.
To open the AVD Manager, do one of
the following: