Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fundamentals of creating Android mobile apps

Fundamentals of creating Android mobile apps

Intro to developing apps on Android for students of CompSci Bristol Uni with basic Java knowledge.

* Android and our tool Kit
* Android App Components
* Development Tips
* Don’t reinvent the wheel (use open source code)
* What next?

Scott Alexander-Bown

November 08, 2019
Tweet

More Decks by Scott Alexander-Bown

Other Decks in Technology

Transcript

  1. Fundamentals of creating
    Android mobile apps
    Scott Alexander-Bown
    [email protected]
    @scottyab

    View full-size slide

  2. WHO THE HECK IS THIS GUY?
    ➤ Senior Android Developer @ Help Scout
    ➤ Remote, in Bristol
    ➤ Google Developer Expert for Android
    ➤ Founder/Organiser SWMobile Meetup
    ➤ http://swmobile.org
    ➤ Co-Author Android Security Cookbook
    ➤ Follow on Twitter @scottyab
    @scottyab

    View full-size slide

  3. @scottyab
    TOO MUCH CONTENT!

    View full-size slide

  4. AT A GLANCE
    ➤Intro
    ➤Fundamentals
    ➤Android, toolkit and ecosystem
    ➤Android App Components
    ➤Development Tips
    ➤Don’t reinvent the wheel (use open source code)
    ➤What next?

    View full-size slide


  5. “Ok, Google…
    How do I create my
    first Android app”
    https://developer.android.com/training/basics/firstapp/

    View full-size slide

  6. MOBILE APPS != WEB SITE
    ➤ Screen size
    ➤ User context - maps/GPS/bluetooth/camera/accelerometer
    ➤ Platform integration
    ➤ Interaction model - glanciblity not sit down focus
    ➤ Intuitive (focused actions)
    ➤ Work offline
    ➤ Permissions - well defined

    View full-size slide

  7. ANDROID, TOOLKIT AND ECOSYSTEM

    View full-size slide

  8. What is Android?

    View full-size slide

  9. https://developer.android.com
    @scottyab

    View full-size slide

  10. EMULATOR
    ➤ Don’t need an actual device
    ➤ although testing on one is recommended
    ➤ GPS/Cellular/Battery/Virtual sensors
    ➤ Screen recording/Screen shot
    ➤ Snap shots

    View full-size slide

  11. .APK AND DISTRIBUTION
    ➤ Android apps are packaged as .apk or .aab
    ➤ Signed with signing key
    ➤ Upload to the Play Store
    • $25 one off registration fee
    • Screen shots
    • Unique App Id
    developer.android.com/distribute/best-practices/launch/launch-checklist.html

    View full-size slide

  12. ANDROID COMPONENTS
    The core concepts and classes you’ll use on day one

    View full-size slide

  13. @scottyab
    @scottyab

    View full-size slide

  14. ACTIVITY
    ➤ AKA a Screen
    ➤ has distinct lifecycle
    ➤ onCreate()
    ➤ onStart()
    ➤ onResume()
    ➤ onPause()
    ➤ onStop()
    ➤ onDestory()
    https://play.google.com/store/apps/details?id=name.peterscully.learning.activitylifecycle
    @scottyab
    @scottyab

    View full-size slide

  15. RESOURCES AND LAYOUTS
    ➤ Layouts
    • Xml
    ➤ Values
    • Strings
    • Styles
    ➤ Drawables

    View full-size slide

  16. INTENTS (USE FOR OPENING NEW ACTIVITIES)
    ➤ Action
    ➤ Extra
    ➤ Primitives
    ➤ Parcelables
    public void sendMessage(String message) {

    Intent intent = new Intent(this, DisplayMessageActivity.class);

    intent.putExtra(EXTRA_MESSAGE, message);

    startActivity(intent);

    }
    @scottyab
    @scottyab

    View full-size slide

  17. @Override

    protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_display_message);


    Intent intent = getIntent();

    String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);


    TextView messageText = (TextView)findViewById(R.id.messageText);

    messageText.setText(message);

    }

    View full-size slide

  18. SERVICES
    ➤ Background operations
    ➤ Lifecycle
    ➤ Service
    ➤ Bind
    ➤ IntentService
    ➤ Work thread
    ➤ Start with Intent
    @scottyab
    @scottyab

    View full-size slide

  19. ANDROID MANIFEST.XML
    @scottyab

    View full-size slide

  20. DEVELOPMENT TIPS

    View full-size slide

  21. Plan on paper!

    View full-size slide

  22. GET OFF THE UI THREAD - ASYNCTASK
    ➤ Yes, there are better ways (Kotlin Coroutines, RX Java, Threadpool executor, …)
    ➤ But for getting started check out AsyncTask
    ➤ Set up
    ➤ onPreExecute()
    ➤ Do this work in the background
    ➤ doInBackground(arguments)
    ➤ Here’s the result on the main thread for you
    ➤ onPostExecute(result)
    @scottyab
    https://developer.android.com/reference/android/os/AsyncTask

    View full-size slide

  23. SAVING DATA
    ➤ Files (internal and external storage)
    ➤ SQLite
    ➤ Use Room persistent library a wrapper on top of SQLite
    ➤ Shared preferences
    ➤ Simple to use
    ➤ Combine with JSON parsing to save
    @scottyab
    https://developer.android.com/guide/topics/data/data-storage.html#pref

    View full-size slide

  24. MISC TIPS*
    ▸ Logic out of the View (i.e Activity or Fragments)
    ▸ Easier to test
    ▸ Simple architecture (MVP or MVVM)
    ▸ Constructor based dependancies
    ▸ Lock to portrait
    ▸ Test on real devices
    ▸ Min SDK 23
    @scottyab
    * For your first app

    View full-size slide

  25. AVOID*
    ▸ RX Java
    ▸ Dagger
    ▸ Child Fragments
    ▸ Cross platform
    ▸ Bleeding edge!
    ▸ Jetpack Compose
    @scottyab
    * For your first app

    View full-size slide

  26. DON’T REINVENT THE WHEEL
    Dependancies & 3rd Party Libs

    View full-size slide

  27. GRADLE
    ➤ Run from CI and IDE
    ➤ Easy dependancy management
    ➤ Build variants
    • types
    • flavours

    View full-size slide

  28. INCLUDING DEPENDANCIES
    ➤ build.gradle
    @scottyab

    View full-size slide

  29. ANDROID JETPACK
    ➤ UI components provide widgets and
    helpers
    ➤ Architecture components help you design
    robust, testable and maintainable apps.
    ➤ Backward-compatible versions of
    framework components.
    ➤ Miscellaneous utility functions.
    https://developer.android.com/jetpack/
    @scottyab

    View full-size slide

  30. CONVERT JAVA OBJECTS
    INTO JSON AND BACK
    https://github.com/google/gson
    API: GSON
    @scottyab

    View full-size slide

  31. T
    ANDROID-ARSENAL.COM

    View full-size slide

  32. VIDEO CONTENT
    ➤ https://www.youtube.com/user/androiddevelopers/featured
    ➤ https://www.udacity.com/course/android-developer-nanodegree-by-google--nd801

    @scottyab

    View full-size slide

  33. SAMPLE APPS
    ▸ github.com/android/sunflower
    ▸ github.com/google/iosched
    ▸ github.com/googlesamples/android-topeka
    ▸ github.com/nickbutcher/plaid
    ▸ github.com/chrisbanes/philm
    ▸ github.com/JakeWharton/u2020
    ▸ github.com/googlesamples
    @scottyab

    View full-size slide

  34. https://kotlinlang.org

    View full-size slide

  35. @scottyab
    TOO MUCH CONTENT???

    View full-size slide

  36. THANKS
    swmobile.org
    @scottyab
    [email protected]
    QUESTIONS?

    View full-size slide

  37. SWMOBILE MEETUP @scottyab

    View full-size slide