Basic of Android Development

Basic of Android Development

Basic information about android development with a code lab to build your first Koltin app.

85b0d08ca3a40c51cd342dd14ad6edab?s=128

Laurence de Villers

November 21, 2018
Tweet

Transcript

  1. Laurence de Villers @L_de_V Basic of Android Development

  2. Basic of Android • Android Apps are written in Java

    and Kotlin • UI Screens are defined in XML • IDE Android Studio ( base on Intellij ) ◦ Android SDK ◦ Android Monitor • Terminal Commands (adb) • Apps run in a Virtual Marchine • Android Kernel is the Linex Kernel • Build tool is Gradle • App format = .apk
  3. Code Definition and Examples Ressources • developer.android.com • Udacity (Android

    for Beginners and Android MicroDegree) • Android Arsenal ( Android developer portal with tools, libraries, and apps) • CodeLab: https://codelabs.developers.google.com/?cat=Android • Vocab : https://developers.google.com/android/for-all/vocab-words/
  4. Kotlin

  5. Basic of Kotlin What is Kotlin Is a language developed

    by JetBrains. 100% interoperable with Java A language that have Null Safety var b: String? = "abc" b = null // ok val l = b.length // error WHY? variable 'b' can be null var a: String = "abc" a = null // compilation error val l = a.length //ok
  6. Basic of Kotlin Safe Call Operator, witten ?. // If

    'applETS' or 'applETS.mobileapp' is null the function is not called: applETS?.mobileapp?.android = creationOfAndroidMobileApp() val a = "Kotlin" val b: String? = null println(b?.length) println(a?.length) Safe Call can be chains Elvis Operator, witten ?: val l = b?.length ?: -1 In Java int l = b != null ? b.length : -1
  7. Basic of Kotlin The !! Operator val l = b!!.length

    Safe Cast val aInt: Int? = a as? Int val VS var val is immutable same as the final modifier in java var is mutable (can be reassigned)
  8. Android KTX Part of Jetpack Concise, readable code. A suite

    of libraries Android KTX, Testing KTX, ...
  9. UI Screens are defined in XML

  10. Common Android Views Helpful reference https://drive.google.com/file/d/0B5XIkMkayHgRMVljUVIyZzNmQUU/view https://developer.android.com/docs/

  11. None
  12. None
  13. None
  14. None
  15. None
  16. View Groups ( Layout) • ConstraintLayout • CoordinatorLayout • RelativeLayout

    • LinearLayout • ListView • RecyclerView • ScrollView • CardView • etc.
  17. Practice your view

  18. Activity vs Fragment

  19. What is the hardest part of Android Development?

  20. None
  21. Retains value between onCreate and onDestroy // some transient state

    for the activity instance var gameState: String? = null override fun onCreate(savedInstanceState: Bundle?) { // call the super class onCreate to complete the creation of activity like // the view hierarchy super.onCreate(savedInstanceState) // recovering the instance state gameState = savedInstanceState?.getString(GAME_STATE_KEY) // set the user interface layout for this activity // the layout file is defined in the project res/layout/main_activity.xml file setContentView(R.layout.activity_main) }
  22. Retains value between onCreate and onDestroy // We restore some

    state in onCreate(), while we can optionally restore // other state here, possibly usable after onStart() has completed. // The savedInstanceState Bundle is same as the one used in onCreate(). override fun onRestoreInstanceState(savedInstanceState: Bundle?) { textView.text = savedInstanceState?.getString(TEXT_VIEW_KEY) } // invoked when the activity may be temporarily destroyed (onStop), save the instance state here override fun onSaveInstanceState(outState: Bundle?) { outState?.run { putString(GAME_STATE_KEY, gameState) putString(TEXT_VIEW_KEY, textView.text.toString()) } // call superclass to save any view hierarchy super.onSaveInstanceState(outState) }
  23. None
  24. Android Studio

  25. None
  26. None
  27. Gadle Custom build tool used to build android packages android

    { compileSdkVersion 28 defaultConfig { applicationId "com.ldevillers.applets_first_app" minSdkVersion 16 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.android.support:appcompat-v7:28.0.0' … }
  28. Build Your First Android App in Koltin Codelab : bit.ly/applETS_Kotlin

  29. Android Jetpack Accelerate App Development

  30. None
  31. 95% supported devices

  32. Want to learn more about Android ? Join the meetup

    GDG Montreal Android: android-montreal.com
  33. THE END! Questions? Laurence de Villers @L_de_V