This document summarizes a lesson on services and notifications in Android development. It provides an overview of the previous lesson and looks ahead to the final project. It discusses services, their lifecycles, and how to make them more efficient using IntentService. It also covers notifications, syncadapters, and application priority levels. The document reviews what went well and challenges in the previous lesson and answers questions from students. It outlines expectations and ideas for the final project.
4. Prime Directive
‘Regardless of where we are up to, we
understand and truly believe that
everyone did the best job he or she
could, given his or her skills and
abilities, the personal time available,
and the situation at hand.’
5. Difficulty Check
● Who completed the class?
● How long did it take?
● Hands up 1-10 difficulty of the lesson
● Any specific areas of the lesson that require
particular focus?
6. Retro lesson 6 services & notifications
What we learnt last week
● Services
● Application priority
● Alarms
● Transferring data efficiently
● SyncAdapters
● Notifications
7. Services
● Execute long running tasks that shouldn’t be interrupted
● Have a lifecycle but no user interface
● Declared in the AndroidManifest
8. Services
● Run on the main thread - which means…..?
○ AsyncTasks, SyncAdapter, IntentService etc.
● Typically override onStartCommand
● No state methods such as onResume, onPause etc
9. Service Extras
● startForeground(Notification notification);
○ increases priority
○ shouldn’t be killed to clear resources
● IntentService (subclass) provides onHandleIntent which runs off the
main thread
○ Executes Intents sequentially
○ Good for downloading
10. App Priority
● Apps running in the background have a
responsibility to be good citizens!
● Async Task can be used to download files/play
music but risk being deleted when the app is in
the background
● Services allow us to deal with these use cases
13. Test...
● Consider effect on user experience
● Consider component - is it an
Activity or Service?
● User interaction
● And is it background/foreground?
3 Laws
1. Android will ensure a smooth UX
2. Android will keep all activities and
services running unless they violate
the 1st law
3. Android will keep background apps
running unless they violate 1st or 2nd
law
20. Further Watching
Google I/O 2013 - Android Protips 3: Making Apps Work Like Magic
https://www.youtube.com/watch?v=GcNNx2zdXN4
Google I/O 2012 - Android Protips 2:Making Good Apps Great
https://www.youtube.com/watch?v=PwC1OlJo5VM
Google I/O 2011: Android Protips: Advanced Topics for Expert Android App Developers
https://www.youtube.com/watch?v=twmuBbC_oB8
21. SyncAdapter
● Designed to sync local data with web efficiently
● OS Batches requests with other apps to save battery.
● Try not to run when radio is idle
● Auto retry requests
● onPerformSync
23. Notifications
● So far, all solutions of retrieving data/sync go Device ->
Server (Poll)
● Notifications are Server -> Device (Push)-
○ can include payload in json format or request update
■ NB: Requesting too many updates concurrently can
cause server traffic
○ More efficient than polling
25. What went well
● Efficient data transfer very useful
● SyncAdapters - many applications can make use of them
● The 3 laws for application priority - great way to
remember
● Understanding the state radio helps understand why
little data transfers are actually worse!
27. What didn’t go so well
● Less detail in this class
● There is a lot to learn / know to get efficient data
synchronised applications
● Copy n Paste for the sync adapter
● Didn’t delete the old weather data until this
lesson!
● “comment out” refresh button … but woohoo
SyncAdapter
30. Next Lesson - Project
Learning Objectives:
- Final Project
31. Final Project
Your Project must:
Import and build on the latest version of Android Studio
Be entirely self-contained on an Android device (No external devices/bluetooth peripherals).
Include a problem description of the problem your app solves.
Include mocks for all user-facing screens.
Include at least one alternate mock for tablet / large screens.
Implement all mockups, including your tablet layout.
Have at least two distinct Views (ex. a list view and a detail view).
Work properly with the app lifecycle (i.e. resume state on orientation change).
Use permissions responsibly.
Use Intents to move between activities inside your app or to an outside app.
Create and use your own ContentProvider
Use Loaders to move your data to your views.
If the application pulls or sends data to/from a web service or API, it handles this network activity properly
(i.e on the correct thread, does not abuse network resources)
Include only safe-for-work content in your app
32. Final Project Extras
For extra Udacious-ness, include at least two of the following (optional):
Receive Broadcast events and do something meaningful.
Create and use a custom View.
Implement a ShareActionProvider, sharing rich content such as a picture or link.
Use Notifications.
33. Final Project Ideas
● Food ordering app
● Teleprompter app
● Local news app
● App for your company, university or local club
● Education app
● Public transit schedule
● Reddit Reading List
● Github OSS project tracker
● YouTube API
● Twitter API
● Weather API
● www.programmableweb.com/apis/directory
37. See you next but one week..
- Time: Tuesday 31st March 7pm
- Place: SpacePort
- Things needed: You + Questions +
Feedback
- Can contact us if issues:
@blundell_apps / @android_mcr