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

Getting Started in Android Dev 2016

Getting Started in Android Dev 2016

Guest lecture/talk for Comp Sci Bristol University - Nov 2016.

Scott Alexander-Bown

November 07, 2016
Tweet

More Decks by Scott Alexander-Bown

Other Decks in Technology

Transcript

  1. GETTING STARTED
    WITH ANDROID DEV
    2016
    Scott Alexander-Bown
    @scottyab

    View Slide

  2. WHO THE HECK IS THIS GUY?
    ➤ Freelance (remote) Android Developer
    ➤ https://scottyab.com
    ➤ Google Developer Expert for Android
    ➤ Founder/Organiser SWMobile Meetup
    ➤ http://swmobile.org
    ➤ Co-Author Android Security Cookbook
    ➤ Follow on Twitter @scottyab
    @scottyab

    View Slide

  3. @scottyab

    View Slide

  4. AT A GLANCE
    ➤Tools / IDE
    ➤Components
    ➤Dependancies / 3rd Party Libs
    ➤Tips
    *Reminder
    LAB - 11am to Midday, Wednesday 9th November 2016
    Merchant Venturer's Building 2.11 Linux Computer Lab

    View Slide

  5. What is Android?

    View Slide

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

    View Slide

  7. @scottyab

    View Slide

  8. Android Components
    @scottyab

    View Slide

  9. 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

    View Slide

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

    View Slide

  11. DESIGN XML

    View Slide

  12. INTENTS
    ➤ Action
    ➤ Extra
    ➤ Primitives
    ➤ Parcelables
    public void sendMessage(String message) {

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

    intent.putExtra(EXTRA_MESSAGE, message);

    startActivity(intent);

    }
    @scottyab

    View Slide

  13. @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 Slide

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

    View Slide

  15. ANDROID MANIFEST.XML
    @scottyab

    View Slide

  16. LISTS / RECYCLERVIEW
    ➤ Xml Layout for list
    ➤ Layout for the row
    ➤ Adapter
    ➤ Binding
    ➤ ViewHolder
    ➤ RecyclerView.setAdapter(…)
    @scottyab

    View Slide

  17. FRAGMENTS
    ➤ Reusable UI/Logic component
    ➤ Own Lifecycle
    @scottyab

    View Slide

  18. .APK AND DISTRIBUTION
    ➤ Android apps are packaged as .apk files
    ➤ Signed with developer signing key
    ➤ Upload to the Play Store
    • $25 one off registration fee
    • Screen shots
    • Unique App Id
    @scottyab

    View Slide

  19. Dependancies
    and
    3rd party libraries

    View Slide

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

    View Slide

  21. INCLUDING DEPENDANCIES
    ➤ build.gradle
    dependencies {

    /*

    * Google Play services

    */

    compile 'com.google.maps.android:android-maps-utils:0.4.4'

    compile 'com.google.android.gms:play-services-maps:9.6.1'

    compile 'com.google.android.gms:play-services-location:9.6.1'
    @scottyab

    View Slide

  22. INCLUDING DEPENDANCIES (JITPACK)
    compile 'com.github.scottyab:Calligraphy:v2.1.1_LABEL_FOR'
    @scottyab

    View Slide

  23. SUPPORT LIBRARY
    ➤ Backward-compatible versions of
    framework components.
    ➤ UI elements to implement the
    recommended Android layout patterns.
    ➤ Support for different form factors.
    ➤ Miscellaneous utility functions.
    @scottyab

    View Slide

  24. https://github.com/JakeWharton/butterknife
    UI: BUTTER KNIFE
    @scottyab

    View Slide

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

    View Slide

  26. TYPE-SAFE HTTP CLIENT
    MAKES APIS EASY
    SIMPLE ASYNC
    https://github.com/square/retrofit
    API: RETROFIT
    @scottyab

    View Slide

  27. @scottyab

    View Slide

  28. T
    ANDROID-ARSENAL.COM

    View Slide

  29. @scottyab

    View Slide

  30. View Slide

  31. USE GIT
    ➤ GitHub
    ➤ GitLab.com
    ➤ BitBucket
    @scottyab

    View Slide

  32. TIPS
    ▸ Lock to portrait
    ▸ Focus on limited devices
    ▸ Test on demo devices
    ▸ Target SDK 15+ (or even
    21+)
    @scottyab

    View Slide

  33. AVOID
    ▸ Child Fragments
    ▸ Constraint layout
    ▸ Bleeding edge!
    @scottyab

    View Slide

  34. FABRIC / CRASHLYTICS
    ➤ By Twitter
    ➤ Crash Reporting
    ➤ Beta distribution
    ➤ Analytics
    ➤ https://get.fabric.io
    @scottyab

    View Slide

  35. SAMPLE APPS
    ▸ 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 Slide

  36. @scottyab

    View Slide

  37. THANKS
    swmobile.org
    github/scottyab
    @scottyab
    [email protected]
    QUESTIONS?
    LAB - 11am to Midday, Wednesday 9th November 2016
    Merchant Venturer's Building 2.11 Linux Computer Lab

    View Slide

  38. QUESTIONS?
    @scottyab

    View Slide