Successfully reported this slideshow.

Android 101 - Kotlin ( Future of Android Development)

3

Share

Upcoming SlideShare
Kotlin for Android devs
Kotlin for Android devs
Loading in …3
×
1 of 45
1 of 45

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

Related Audiobooks

Free with a 14 day trial from Scribd

See all

Android 101 - Kotlin ( Future of Android Development)

  1. 1. Hassan Abid GDE Android - Singapore @hassanabidpk Android 101 Kotlin - Future of Android Development
  2. 2. ● Mainly work as Android developer ● Google Developers Expert for Android ● Contributed in apps and SDKs: KineMaster, Rakuten LIVE, BeLive, NexPlayer SDK (Android, iOS, Unity, Tizen) About me Lead Software Engineer
  3. 3. ● My Android Journey ● Why Kotlin ● Kotlin 101 ● Kotlin Vs. Java ● Advance Kotlin ● Learning Resources Content
  4. 4. ● Started learning on my own in 2011 from developers.android.com ● Joined Android Study meetup with Geeks in 2011 ● Tried to contribute in a very difficult project in 2011 ● Got first internship for developing Tablet UI in 2012 (Life changing move) ● Mentored and taught my friends about Android dev in 2015 (Udacity course) ● Finished Android Nanodegree in dec 2015 ● Became Android GDE In 2016 My Android Journey
  5. 5. “10 years and now over 2.5 billion active devices produced by more than 180 hardware manufacturers” - Android director Stephanie Cuthbertson
  6. 6. ● Android Studio 3.5 released ● Kotlin is Google’s preferred language of Android ● Official documentation : https://developer.android.com ● Official Samples : https://developer.android.com/samples Android Latest version of Android (10) was released last week
  7. 7. Why Kotlin?
  8. 8. Kotlin on android since 2017
  9. 9. Kotlin popularity Survey link In the latest Stack Overflow developer survey, it ranks as the fourth-most loved programming language.
  10. 10. Apps built with Kotlin
  11. 11. ● Kotlin is a modern statically typed programming language ● It’s pragmatic and concise, and makes coding a satisfying and efficient experience. ● Kotlin is 100% interoperable with Java Kotlin 101 Developed by JetBrain
  12. 12. Kotlin vs. Java
  13. 13. // Kotlin Hello World fun main(args: Array<String>) { println("Hello World!") } // Java Hello World class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }
  14. 14. What Kotlin has that java does not
  15. 15. // Nullable types and Non-Null Types // Case 1 var a: String = "abc" a = null // compilation error // Case 2 var b: String? = "abc" b = null // ok print(b)
  16. 16. // Checking for null in conditions val b: String? = "Kotlin" if (b != null && b.length > 0) { print("String of length ${b.length}") } else { print("Empty string") }
  17. 17. // Safe Calls val a = "Kotlin" val b: String? = null println(b?.length) println(a?.length) // Unnecessary safe call
  18. 18. // Safe Calls val a = "Kotlin" val b: String? = null println(b?.length) println(a?.length) // Unnecessary safe call // The !! Operator val l = b!!.length
  19. 19. // Extension Functions fun MutableList<Int>.swap(index1: Int, index2: Int) { val tmp = this[index1] // 'this' corresponds to the list this[index1] = this[index2] this[index2] = tmp } // Usage val list = mutableListOf(1, 2, 3) list.swap(0, 2) // 'this' inside 'swap()' will hold the value of 'list'
  20. 20. // Data Classes data class User(val name: String = "", val age: Int = 0) data class Person(val name: String) { var age: Int = 0 } val jane = User("Jane", 35) val (name, age) = jane println("$name, $age years of age") // prints "Jane, 35 years of age"
  21. 21. // Smart Casts fun demo(x: Any) { if (x is String) { print(x.length) // x is automatically cast to String } } // Smart cast for when expression when (x) { is Int -> print(x + 1) is String -> print(x.length + 1) is IntArray -> print(x.sum()) }
  22. 22. ● Read more at https://kotlinlang.org/docs/reference/coroutines-overview.html ● Code Lab : https://codelabs.developers.google.com/codelabs/kotlin-coroutines/#0 Coroutines Lightweight threads
  23. 23. // Async callbacks networkRequest { result -> // Successful network request databaseSave(result) { rows -> // Result saved } } // The same code with coroutines val result = networkRequest() // Successful network request databaseSave(result) // Result saved
  24. 24. // Android Kotlin Extensions - KTX // Before KTX sharedPreferences .edit() // create an Editor .putBoolean("key", value) .apply() // write to disk asynchronously // After KTX // Commit a new value asynchronously sharedPreferences.edit { putBoolean("key", value) }
  25. 25. MORE HERE : https://play.kotlinlang.org/hands-on/overview
  26. 26. Learning Resources
  27. 27. ● Kotlin only docs : https://kotlinlang.org/docs/reference/ ● Kotlin for android docs : https://developer.android.com/kotlin ● Android Code Labs for Kotlin : https://codelabs.developers.google.com/?cat=Kotlin ● Android Developers YouTube Channel : https://www.youtube.com/user/androiddevelopers Official Resources Kotlin and Android
  28. 28. Code Labs
  29. 29. Udacity All courses link Free courses from Google
  30. 30. Udacity Android Nanodegree link Basic and Advance Android Nanodegree
  31. 31. Associate Android Developer Certifications Link : https://developers.google.com/training/certification/ associate-android-developer/
  32. 32. @hassanabidpk Thank You!

×