Рассмотрим, как можно использовать возможности вашего устройства (в том числе, его сенсоров) и некоторые приемы UX для того, чтобы улучшить производительность и удобство использования вашего приложения.
3G/4G data costs money All of them drain the battery Users don’t like losing money or battery! Users want the best UX! the second she wakes up... Does not like waiting! Wants fresh data...
3G/4G data costs money All of them drain the battery Users don’t like losing money or battery! Users want the best UX! Internet is not everywhere!!! (= Example: metro!)
uses nothing) Radio download mode (working, needs POWER!!!) Radio idle mode: Does (almost) nothing Still uses power (300 mA) • Lasts up to 90 seconds (!!!)
Workflow: Phone radio is at “baseline” App A needs to fetch from server Radio goes to “download” Data downloaded Radio goes to “idle” • Radio waits 90 seconds (in “idle”)
Workflow: Phone radio is at “baseline” App A needs to fetch from server Radio goes to “download” Data downloaded Radio goes to “idle” Radio waits 90 seconds (in “idle”) • Radio goes to “baseline”
Workflow: Phone radio is at “baseline” App A needs to fetch from server Radio goes to “download” Data downloaded Radio goes to “idle” Radio waits 90 seconds (in “idle”) Radio goes to “baseline”
08:15 - App A update (every 60 minutes) 09:00 - App B update (every day at 09:00) 09:07 - App C update (FCM induced) 09:15 - App A update (every 60 minutes) 09:35 - App G update (every 2 hours) ... 13:30 - Royi checks the phone in his pocket
puts phone in pocket 08:15 - App A update (every 60 minutes) 09:00 - App B update (every day at 09:00) 09:07 - App C update (FCM induced) 09:15 - App A update (every 60 minutes) 09:35 - App G update (every 2 hours) ... 13:30 - Royi checks the phone in his pocket
Use FCM push notifications Push receivers work while radio is at baseline mode The server notifies you when something changed - Nothing’s changed, cancel call = no wasted idle and downloading times
Use FCM push notifications Use system connectivity check API Searching for connectivity is more costly than calls - App level queries keeps app loaded and the CPU running
Use FCM push notifications Use system connectivity check API Searching for connectivity is more costly than calls App level queries keeps app loaded and the CPU running - Apps rarely use exponential back-off algorithms
Use FCM push notifications Use system connectivity check API: ConnectivityManager (one batched check for all apps) • Schedulers (use ConMag automatically, use exponential back-off)
when device is unused & not charging When applied it forces network batching To comply: Test app while in doze mode • If applicable - set right priority for AlarmManager
when device is unused & not charging When applied it forces network batching To comply: Test app while in doze mode • If applicable - set right priority for AlarmManager (=setAndAllowWhileIdle()/setExactAndAllowWhileIdle())
00:00 - App B update 01:13 - App E update 02:00 - App C, D update 03:15 - App A update 04:00 - App B, D update 05:30 - Royi checks phone on night stand
00:00 - App B update 01:13 - App E update 02:00 - App C, D update 03:15 - App A update 04:00 - App B, D update 05:30 - Royi checks phone on night stand 05:31 - Royi is angry because he has 23% battery
00:00 - App B update 01:30 - App B,E update 02:00 - App C, D update 03:15 - App A update 04:00 - App A, B, C, D update 05:30 - Royi checks phone on nightstand 05:31 - Royi is happy because he has 43% battery
listeners (screen, network, battery, dock) Awareness API (Activity, location, Beacons, Headphones) - *Supported back to Froyo (2.2) *Caution: getBeaconState() is only supported on devices running API level 18 (Jelly Bean) or higher. If calling from a device running an earlier version, getStatus() will return status code API_NOT_AVAILABLE.