Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Using Kotlin in Android
Search
Ivan
May 03, 2019
Programming
0
110
Using Kotlin in Android
Kotlin examples for study group in Taiwan Kotlin User Group
Ivan
May 03, 2019
Tweet
Share
More Decks by Ivan
See All by Ivan
KtRssReader 的奇幻旅程
ivanw
0
88
Kotlin Flow Application and Testing on Android
ivanw
0
300
Kotlin Flow Application and Testing on Android
ivanw
1
440
A Step-by-Step Guide to Kotlin Flow 手把手帶你認識 Kotlin Flow
ivanw
0
200
Coroutines Made Easy
ivanw
1
190
All About KotlinConf 2019
ivanw
0
130
Writing Tests in Kotlin
ivanw
0
340
Other Decks in Programming
See All in Programming
Blazing Fast UI Development with Compose Hot Reload (droidcon New York 2025)
zsmb
1
190
Elixir で IoT 開発、 Nerves なら簡単にできる!?
pojiro
1
150
AIコーディング道場勉強会#2 君(エンジニア)たちはどう生きるか
misakiotb
1
240
Go1.25からのGOMAXPROCS
kuro_kurorrr
1
800
都市をデータで見るってこういうこと PLATEAU属性情報入門
nokonoko1203
1
560
GoのGenericsによるslice操作との付き合い方
syumai
3
680
A2A プロトコルを試してみる
azukiazusa1
2
1.1k
Bytecode Manipulation 으로 생산성 높이기
bigstark
2
370
『自分のデータだけ見せたい!』を叶える──Laravel × Casbin で複雑権限をスッキリ解きほぐす 25 分
akitotsukahara
1
490
Team operations that are not burdened by SRE
kazatohiei
1
180
XP, Testing and ninja testing
m_seki
3
180
Webからモバイルへ Vue.js × Capacitor 活用事例
naokihaba
0
760
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Building a Modern Day E-commerce SEO Strategy
aleyda
41
7.3k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.6k
Into the Great Unknown - MozCon
thekraken
39
1.9k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.8k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3k
Testing 201, or: Great Expectations
jmmastey
42
7.5k
Practical Orchestrator
shlominoach
188
11k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
It's Worth the Effort
3n
185
28k
Transcript
Using Kotlin in Android Ivan W.
Outline • Null Safety • Data Class • Default Argument
/ Implementation 2
Null Safety • Eliminate the danger of null references from
code • Nullable types and Non-Null Types var a: String = "abc" a = null // compilation error var b: String? = "abc" b = null // ok 3 Nullable types Non-Null types
Example 1 4 Bundle args = getArguments(); if (args !=
null) { Bundle data = args.getBundle(KEY_DATA); if (data != null) { Log.d(TAG, data.getString(KEY_NAME)); } } Java
Example 1 5 Bundle args = getArguments(); if (args !=
null) { Bundle data = args.getBundle(KEY_DATA); if (data != null) { Log.d(TAG, data.getString(KEY_NAME)); } } Log.d(TAG, arguments?.getBundle(KEY_DATA)?.getString(KEY_NAME)) Java Kotlin
Data Class • It automatically generates ◦ equals() / hashCode()
◦ getters and setters ◦ toString() ◦ copy()
Example 2 7 Java Kotlin See example See example
Default Argument / Implementation 8 • Java overloads can be
replaced with one function in Kotlin
Example 3 9 private void sendInfo(String content, long Time, String
tag) { /* ... */ } private void sendInfo(String content, long Time) { /* ... */ } private void sendInfo(String content, String tag) { /* ... */ } private void sendInfo(String content) { /* ... */ } Java
Example 3 10 private fun sendInfo( content: String, time: Long
= Date().time, tag: String = TAG ) { … } sendInfo("content", time = Date().time) Kotlin
Example 4 11 Java Kotlin See example See example
Thank you! 12