Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Android with Kotlin
Search
Ahmed Tarek
October 12, 2017
Programming
0
160
Android with Kotlin
Slides from my talk Android with Kotlin at Oct 2017 GDG 6 October City, Egypt.
Ahmed Tarek
October 12, 2017
Tweet
Share
Other Decks in Programming
See All in Programming
チームをチームにするEM
hitode909
0
370
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
280
20251212 AI 時代的 Legacy Code 營救術 2025 WebConf
mouson
0
210
ZJIT: The Ruby 4 JIT Compiler / Ruby Release 30th Anniversary Party
k0kubun
0
270
認証・認可の基本を学ぼう後編
kouyuume
0
250
Claude Codeの「Compacting Conversation」を体感50%減! CLAUDE.md + 8 Skills で挑むコンテキスト管理術
kmurahama
1
630
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
360
AI Agent Dojo #4: watsonx Orchestrate ADK体験
oniak3ibm
PRO
0
110
AIコーディングエージェント(skywork)
kondai24
0
200
公共交通オープンデータ × モバイルUX 複雑な運行情報を 『直感』に変換する技術
tinykitten
PRO
0
160
Patterns of Patterns
denyspoltorak
0
310
生成AI時代を勝ち抜くエンジニア組織マネジメント
coconala_engineer
0
780
Featured
See All Featured
Reality Check: Gamification 10 Years Later
codingconduct
0
1.9k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.1k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
0
250
From π to Pie charts
rasagy
0
91
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
72
Designing for Performance
lara
610
69k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Abbi's Birthday
coloredviolet
0
3.7k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
It's Worth the Effort
3n
187
29k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
69
Transcript
Android with Kotlin a_tarek360 Oct, 2017
What is kotlin?
Kotlin is a Russian island
Kotlin • By JetBrains in 2011 • Open sourced in
2012 • The first officially stable release in 2016
At Google I/O 2017, Google announced..
Kotlin • Official Programming Language for Android Development
Kotlin • Statically typed programming language • 100% interoperable with
Java and Android • Avoid entire classes of errors such as null pointer exceptions.
var / val var name = "Ahmed" val id =
1 Val cannot be reassigned id = 3
Null Safety Safe var name: String name = null //
Compilation error Nullable val name: String? = null // Nullable type println(name.length()) // Compilation error println(name?.length())
Classes/Interfaces class SimpleClass class SimpleClass(value: String) interface SimpleInterface class SimpleClass
: BaseClass(), SimpleInterface
Data Class data class Car( var name: String, var color:
Int, var speed: Float) • No need to implement: toString, equals
Functions fun isMoving(speed: Int): Boolean { return speed > 0
} fun isMoving(speed: Int) = speed > 0
Companion Object class Car { companion object { fun drive()
{ } } } // Like calling a static method Car.drive()
Simple Android Activity class MainActivity : Activity() { override fun
onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val name = savedInstanceState?.getString("name") } }
Extending Language isLollipop { view.elevation = 3.0f } . .
. . inline fun isLollipop(code: () -> Unit) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { code.invoke() } }
Smart Cast fun setData(view: View) { if (view is ImageView)
{ view.setImageDrawable(drawable) } if (view is TextView) { view.setText("hello") } }
Callback/Lambda • view.setOnClickListener(object : View.OnClickListener { override fun onClick(view: View?)
{ doSomething() } }) • view.setOnClickListener { view -> doSomething(view) } • view.setOnClickListener { doSomething() }
Function Parameter Default Value fun toast(message: String) { Toast.toast(this, message,
Toast.LENGTH_LONG).show() } fun toast(message: String, duration: Int) { Toast.makeText(this, message, duration).show() } fun toast(message: String, duration: Int = Toast.LENGTH_LONG) { Toast.makeText(this, message, duration).show() }
Extension Functions fun Activity.toast(message: String, duration: Int = Toast.LENGTH_LONG) {
Toast.makeText(this, message, duration).show() } // Call it from any activity instance toast("Hello World!") toast("Hello World!", Toast.LENGTH_SHORT)
Kotlin Android Extensions <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/photo" … />
<TextView android:id="@+id/name" … /> </RelativeLayout>
Kotlin Android Extensions import kotlinx.android.synthetic.main.activity_main.* override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) photo.setImageBitmap(bitmap) name.setText("Hello World!") }
Thank You!