Common causes
● I/O operations (Network requests, Database Access)
Slide 9
Slide 9 text
Common causes
● I/O operations (Network requests, Database Access)
● Long calculations (Image processing)
Slide 10
Slide 10 text
The result
https://developer.android.com/topic/performance/images/anr-example-framed.png
Slide 11
Slide 11 text
Why bother?
⭐⭐⭐⭐⭐
Slide 12
Slide 12 text
Why bother?
⭐⭐⭐⭐⭐
Slide 13
Slide 13 text
Why bother?
⭐⭐⭐⭐⭐
⏱⏱⏱⏱⏱
Slide 14
Slide 14 text
Solution - Android
AsyncTask
Slide 15
Slide 15 text
AsyncTask
● Impossible to cancel a task
Slide 16
Slide 16 text
AsyncTask
● Impossible to cancel a task
● Potential memory leaks
Slide 17
Slide 17 text
Solution - Kotlin
Coroutines
Slide 18
Slide 18 text
Coroutines
● Beyond the scope of this talk, sadly…
Slide 19
Slide 19 text
Solution - Open Source library
Slide 20
Slide 20 text
RxJava
“RxJava is a Java VM implementation of ReactiveX a
library for composing asynchronous and event-based
programs by using observable sequences.”
Slide 21
Slide 21 text
RxJava
Subscriber Observable
subscriber.onNext()
Slide 22
Slide 22 text
RxJava - Schedulers
“Executes arbitrary blocks of code, possibly in the future”
Slide 23
Slide 23 text
RxJava - Schedulers
“Executes arbitrary blocks of code, possibly in the future”
Schedulers + subscribeOn()
Slide 24
Slide 24 text
RxJava - Schedulers
“Executes arbitrary blocks of code, possibly in the future”
Schedulers + subscribeOn() + observeOn()
Slide 25
Slide 25 text
Schedulers.io()
● Unbounded pool of threads
Slide 26
Slide 26 text
Schedulers.io()
● Unbounded pool of threads
● Threads are recycled
Slide 27
Slide 27 text
Schedulers.io()
● Unbounded pool of threads
● Threads are recycled
● Used for I/O bound tasks
Slide 28
Slide 28 text
Schedulers.io()
● Unbounded pool of threads
● Threads are recycled
● Used for I/O bound tasks
● Tasks take some time to complete
Slide 29
Slide 29 text
Schedulers.computation()
● Bounded pool of threads
Slide 30
Slide 30 text
Schedulers.computation()
● Bounded pool of threads
● Used for CPU intensive tasks
Slide 31
Slide 31 text
Schedulers.computation()
● Bounded pool of threads
● Used for CPU intensive tasks
● Computation threads limited to the number of
CPU cores
Slide 32
Slide 32 text
Schedulers.trampoline()
● Schedules tasks in the same thread
Slide 33
Slide 33 text
Schedulers.trampoline()
● Schedules tasks in the same thread
● Blocking, but waits for the current task to finish
Slide 34
Slide 34 text
subscribeOn()
● Determines the thread which the source
observable emits on
Slide 35
Slide 35 text
subscribeOn()
● Determines the thread which the source
observable emits on
● Works upstream - only the first call counts
Slide 36
Slide 36 text
subscribeOn()
What thread will the source observable emit on?
Observable.just("Hello", "World")
.subscribeOn(Schedulers.io())
.subscribeOn(Schedulers.computation())
...
Slide 37
Slide 37 text
observeOn()
● Switches the current observable to the specified
thread
Slide 38
Slide 38 text
observeOn()
● Switches the current observable to the specified
thread
● Works downstream - only the last call counts
Slide 39
Slide 39 text
observeOn()
What thread will the current observable be emitted on?
Observable.just("Hello", "World")
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
...
Slide 40
Slide 40 text
TestScheduler
“A special, non thread-safe scheduler for testing
operators that require a scheduler without introducing
real concurrency and allows manually advancing a
virtual time.”
What are employers looking for?
● Technical Experience suitable for the role
Slide 68
Slide 68 text
What are employers looking for?
● Technical Experience suitable for the role
● “Soft” skills
Slide 69
Slide 69 text
What are employers looking for?
● Technical Experience suitable for the role
● “Soft” skills
● Growth potential
Slide 70
Slide 70 text
What are employers looking for?
● Technical Experience suitable for the role
● “Soft” skills
● Growth potential
● Bonus - Writing skills
Slide 71
Slide 71 text
What are employers looking for?
● Technical Experience suitable for the role
● “Soft” skills
● Growth potential
● Bonus - Writing skills
● Bonus - Contributions to the community
Slide 72
Slide 72 text
Building a career
portfolio
Slide 73
Slide 73 text
Building a career portfolio
● Contribute to an existing project
Slide 74
Slide 74 text
Building a career portfolio
● Contribute to an existing project
● Upload code snippets or sample apps to Github
Slide 75
Slide 75 text
Building a career portfolio
● Contribute to an existing project
● Upload code snippets or sample apps to Github
● Publish apps on Google Play
Slide 76
Slide 76 text
Building a career portfolio
● Contribute to an existing project
● Upload code snippets or sample apps to Github
● Publish apps on Google Play
● Write technical articles
Slide 77
Slide 77 text
Building a career portfolio
● Contribute to an existing project
● Upload code snippets or sample apps to Github
● Publish apps on Google Play
● Write technical articles
● Give talks
Slide 78
Slide 78 text
How to find
opportunities
Slide 79
Slide 79 text
How to find opportunities
● Social media (LinkedIn, Twitter, StackOverflow Jobs)
Slide 80
Slide 80 text
How to find opportunities
● Social media (LinkedIn, Twitter, StackOverflow Jobs)
● Newsletters (Forloop, Android/Kotlin Weekly)
Slide 81
Slide 81 text
How to find opportunities
● Social media (LinkedIn, Twitter, StackOverflow Jobs)
● Newsletters (Forloop, Android/Kotlin Weekly)
● Job Search marketplace (Hired.com, Fiverr, Upwork)
Slide 82
Slide 82 text
How to find opportunities
● Social media (LinkedIn, Twitter, StackOverflow Jobs)
● Newsletters (Forloop, Android/Kotlin Weekly)
● Job Search marketplace (Hired.com, Fiverr, Upwork)
● Company Career pages
Slide 83
Slide 83 text
How to find opportunities
● Social media (LinkedIn, Twitter, StackOverflow Jobs)
● Newsletters (Forloop, Android/Kotlin Weekly)
● Job Search marketplace (Hired.com, Fiverr, Upwork)
● Company Career pages
● Employee referrals
Slide 84
Slide 84 text
Questions?
Slide 85
Slide 85 text
Resources
● https://developer.android.com/training/articles/perf-anr
● http://hvasconcelos.github.io/articles/Offloading-work-from-the-
UI-Thread
● https://blog.gojekengineering.com/multi-threading-like-a-boss-in
-android-with-rxjava-2-b8b7cf6eb5e2
● https://square.github.io/retrofit/
● Reactive Programming with RxJava - Tomasz Nurkiewicz
Slide 86
Slide 86 text
Take home task
Slide 87
Slide 87 text
Take home task
Create a one page app with GitHub’s public REST API,
listing all names of users in Lagos.
The app should make use of both RxJava and Retrofit for
networking. Make the network request on the io thread.
For bonus points, use an Android App architecture and
write tests.