4. What is Android?
The Android operating system is a mobile operating system that was
developed by Google to be primarily used for touchscreen devices,
cell phones, and tablets. Its design lets users manipulate the mobile
devices intuitively, with finger movements that mirror common
motions, such as pinching, swiping, and tapping. Google also
employs Android software in televisions, cars, and wristwatches—
each of which is fitted with a unique user interface.
5. •Open source operating system
•Open ecosystem
•Diverse phone options
•Customized or modified ROM
•User-friendly Play Store
•Easy and affordable app development
•Widgets
•Expandable storage option
Features/Advantages
8. FEATURE NATIVE DEVELOPMENT CROSS-PLATFORM DEVELOPMENT
Target Platform Single platform (Android) Multiple platforms (Android, iOS, etc.)
Development Tools Android Studio, SDK specific tools
Framework specific tools (React
Native, Flutter, etc.)
Performance Superior
Good, but may not be as smooth as
native
User Interface/User Experience (UI/UX)
Native look and feel, full access to
platform UI components
Can look and feel "off" compared to
native apps, limited access to
platform UI components
Development Time
Longer, requires platform-specific
knowledge
Faster, can reuse code across
platforms
Maintenance
Separate codebases for each
platform
Single codebase for all platforms
Cost
Usually more expensive due to
separate codebases
Can be more cost-effective,
especially for multi-platform projects
11. ● Shorter program for the same task.
● Kotlin is a statically-typed language which is very easy to read and write.
● It has a much simpler and shorter code than Java’s code for the same problem.
● As this makes the language more human-readable, it becomes easy to debug.
● Kotlin programs do not need semicolons in their program.
● Java Compatibility - Java and Kotlin code can co-exist in the same project.
● Kotlin plays well with the Java programming language.
● Moreover, a number of Java libraries can be used in Kotlin projects, making it even
more compatible.
12. What is JVM?
The Java Virtual Machine (JVM) is an interpreter that
executes Java applications.
You use the JVM to run the Android Studio IDE and
the Gradle build tool.
Java Virtual Machine
13. What is SDK?
A software development kit (SDK) is a set of platform-
specific building tools for developers.
You require components like debuggers, compilers, and
libraries to create code that runs on a specific platform,
operating system, or programming language.
Software Development Kit
14.
15. What is Kotlin?
Kotlin is a general purpose, free, open source, statically
typed programming language designed for the JVM
(Java Virtual Machine) & Android, and combines object-
oriented and functional programming features.
16. It can be used in :
1. Native Development
2.Data Science
3.Server-Side
4.Web-Development
5.Android
Where it can be used?
17. About Null Pointer Exception
When we use C++ or Java , and if we assign any String a null value and get a
comparison check it will provide us with a NullPointerException and hence in
Kotlin we won’t get that error as Kotlin wouldn’t let that happen and will not let
you change the value of String to null. But still if you want to change it null then
you need to add a question mark in the end of String as shown above.
19. Variable in Kotlin
By default Kotlin, defines the data type of the variable by its own.
But we can also type cast it or define it by using : “data_type”
20. ● Val : Val is a final value that can’t be reassigned.
● Var : Var can be reassigned and also we can’t change the
data type of var once declared.
Difference between Val and Var
21. About Lateinit
It is used to set the value of any variable with data type
var in the later code. It’s full form is Late Initialization
lateinit var x: String
22. Null Safety
var f:String? = null //here we are assigning the value of f as
null
fun main(){
val size = f?.length //now we are assigning the value of f(i.e.
null) to size.
val size: Int = f?.length //This will show an error as the data type
asked is Int which is not nullable
val size: Int? = f?.length // Now the data type becomes nullable too
println(size)
}
As we don’t know the size of f as it is null and the size can be null as well hence
we used ? to specify that f is nullable.
23. var f:String? = null
fun main(){
val size: Int = f?.length ?: 0
println(size)
}
val size: Int = f?.length ?: 0
// The above line expresses that if the left hand side of :
comes out to null then assign it the right hand side value
24. Merge two strings
String Concatenation
var f:String = “Krish"
fun main(){
println(f + “is the host"
}
The similar way to do is :-
var f:String = “Krish"
fun main(){
println("$f is the host")
println("The length of his name is ${f.length}")
}
25. An array is a group of similar elements or data items of
the same type collected at contiguous memory locations.
Arrays
val numbers = arrayOf(1,2,3,4,5,6)
println(numbers.joinToString())
val nameString = arrayof<String>("1","2","3","4")
Right now, we haven't specified the type of array, but we can do so by
26. Introduction to Classes
class User{
val name: String = "“
val mobile: Int = 1
val gender: String = "“
val email: String =""
val bio: String = ""
}
28. TextView
TextView is a user interface (UI) widget that displays text messages on a screen
<TextView
android:text=""
android:layout_wdith=""
android:layout_height="" />
android:layout_wdith="" & andorid:layout_height="" are the mandatory attributes to create any
view in the XML File.
android:text=""→ It is used to type in the text we want to write
android:textSize="" → Here we are required to provide the size to the text we wrote
match_parent → It takes the maximum size of the parent
wrap_content → It takes the size which is least required to view the object
android:gravity="" → It is about alignment of the text present in TextView
Now lets code in android studio
29. Linear Layout
TextView is a user interface (UI) widget that displays text messages on a screen
<LinearLayout
android:orientation="vertical" />
Here the orientation is set to vertical, hence all the views present the Layout will
be aligned vertically. Similarly we try using the horizontal layout using the
following code.
Now lets code in android studio
<LinearLayout
android:orientation="horizontal" />
31. Weights
Now lets code in android studio
andorid:layout_weight=""
This will tell how much weightage will each view have on the screen.
Usage-
If we are dividing two views horizontally then we should rest its width to 0dp as we have
divided them equal weightage to both of them on the screen so no width is required now
And like if we want to distribute the text view equally under a layout we can simply apply
this attribute to each view under it so the weightage is equal to every view and hence it
gets equally distributed.
32. Margins & Padding
Now lets code in android studio
In Margin, the area gets subtracted from the view, but in the Padding the areas gets added
to it.
Now to use margins for a particular view we can use the attribute as
andorid:layout_margin="" and here we will provide the dp of margin required.
If you want margin only on the top then you can use android:layout_marginTop="“
android:padding="" → Here we can use the padded size in the View
dp : density-independent pixel, (dip/ dp) is a unit of length
34. Types of Layouts
Frame Layout – Android Frame layout is a ViewGroup subclass that is used to specify the
position of multiple views placed on top of each other to represent a single view screen.
Relative Layout – Relative Layout is a view group that displays child views in relative
positions. The position of each view can be specified as relative to sibling elements (such as
to the left-of or below another view) or in positions relative to the parent Relative Layout area
(such as aligned to the bottom, left or center).
Constraint Layout - It is the default layout provided by the Android Studio. Constraint Layout
is similar to Relative Layout, but with more power. It arranges views based on connections
between sibling views and the parent layout.
Now lets code in android studio
35. fun showtoast(view: View){
Toast.makeText(this, "This is a button click.",Toast.LENGTH_SHORT)
.show()
}
Now lets code in android studio
android:onClick="showtoast“ provides you a function as showtoast that gets
performed when we click the button.
This is about XML file but now we will get to the MainActivity.kt file then we will
get a method showtoast and you can modify it.
<Button
android:layout_width=""
android:layout_height=""
android:onClick="" />
BUTTON