Video and slides synchronized, mp3 and slide download available at URL http://bit.ly/1shcgNu.
Mo Ramezanpoor discusses how two different activity tracking apps -"Zombies, Run!" and "The Walk"- have different approaches for tracking user activity. Filmed at qconlondon.com.
Mo Ramezanpoor is a software developer working mainly on iOS apps. Last year he joined Six to Start, where he is the lead developer for fitness game Zombies, Run!. Mo has studied Astrophysics and has experience in writing data processing and simulation software.
2. Watch the video with slide
synchronization on InfoQ.com!
http://www.infoq.com/presentations
/sensors-tracking-user-activity
InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
3. Presented at QCon London
www.qconlondon.com
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
5. Agenda
A look at fitness tracking apps!
• Tailored data processing
• Adapting the UI
Overcoming device limitations!
• Reducing battery use
• Keeping the app alive
Handling sensor data!
• Keeping track of time
• Distance calculation
10. Reducing battery use
Don’t use CPU if you can!
• Get data points in batches
• Don’t use standalone timers to update the UI
• Defer data processing as much as possible
Only ask for the accurate that you need!
• Accurate location data will require multiple antennae
• Accurate motion data will require multiple sensors
• Accurate data points are computationally more expensive to produce
12. Keeping the app alive (iOS)
Play audio in the background!
• If you already need to play audio in the background
• If you need to completely stop the device from sleeping
Track location!
• Using significant location change updates
• Using explicit location tracking but with low accuracy
Use notifications!
• If your app’s behaviour depend on external sources
• f you have can assume network connectivity
15. “Absolute” time
26 35 44…ticks since first tick!
“System” time
182 186 190…seconds since reference
16. “Absolute” time
26 35 44…ticks since first tick!
“System” time
182 186 190…seconds since reference
“Calendar” time
13:30:08 13:30:12 13:30:16…on March 7, 2014
17. Calendar time jumps
“System” time
“Calendar” time
…seconds since reference
…on March 30, 2014
18. Calendar time jumps
“System” time
312
“Calendar” time
10:59:58
GMT
…seconds since reference
…on March 30, 2014
19. Calendar time jumps
“System” time
312
“Calendar” time
10:59:58
GMT
313
10:59:59
GMT
…seconds since reference
…on March 30, 2014
20. Calendar time jumps
“System” time
314
312
“Calendar” time
10:59:58
GMT
313
10:59:59
GMT
…seconds since reference
…on March 30, 2014
21. Calendar time jumps
“System” time
314
312
“Calendar” time
10:59:58
GMT
313
10:59:59
GMT
…seconds since reference
Timezone changes
…on March 30, 2014
22. Calendar time jumps
“System” time
314
312
“Calendar” time
10:59:58
GMT
313
10:59:59
GMT
…seconds since reference
Timezone changes
03:00:00
Pacific Time
…on March 30, 2014
23. Calendar time jumps
“System” time
“Calendar” time
…seconds since reference
…on March 30, 2014
24. Calendar time jumps
“System” time
312
“Calendar” time
00:59:58
GMT
…seconds since reference
…on March 30, 2014
25. Calendar time jumps
“System” time
312
“Calendar” time
00:59:58
GMT
313
00:59:59
GMT
…seconds since reference
…on March 30, 2014
26. Calendar time jumps
“System” time
314
312
“Calendar” time
00:59:58
GMT
313
00:59:59
GMT
…seconds since reference
…on March 30, 2014
27. Calendar time jumps
“System” time
314
312
“Calendar” time
00:59:58
GMT
313
00:59:59
GMT
…seconds since reference
Daylight saving starts
…on March 30, 2014
28. Calendar time jumps
“System” time
314
312
“Calendar” time
00:59:58
GMT
313
00:59:59
GMT
…seconds since reference
Daylight saving starts
02:00:00
BST
…on March 30, 2014
29. Calendar time jumps
Managing calendar date and time is hard!
… but is not our problem!
… as long as we don’t use them!
37. “Anchored” Time
“Absolute” time
26 35 44…ticks
+295 +295 +195…offset
“System” time
Network date update
312 313 213
…seconds since reference
38. “Anchored” Time
“Absolute” time
26 35 44…ticks
17 18 19…seconds since boot
+295 +295 +195…offset
“System” time
Network date update
312 313 213
…seconds since reference
40. “Anchored” Time
On iOS:!
• Use CACurrentMediaTime() as AbsoluteTime().
• Use [NSDate timeIntervalSinceReferenceDate] as SystemTime().
!
On Android:!
• Use SystemClock.elapsedRealtimeNanos() as AbsoluteTime().
• Use System.currentTimeMillis() as SystemTime().
• Also see Location.getElapsedRealtimeNanos().
63. Distance calculation
Remove points that!
1. have unacceptably low accuracy
2. are too close to the points before or after them
Don’t remove points that!
1. the user has seen
2. are “too far”, unless you really know what you’re doing