Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Les AsyncTasks
Search
Souleymane Sidibe
February 15, 2014
Programming
71
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Les AsyncTasks
Souleymane Sidibe
February 15, 2014
More Decks by Souleymane Sidibe
See All by Souleymane Sidibe
Android new UI ToolKit: Jetpack Compose
soulesidibe
0
180
Code sharing with Kotlin multi-platform
soulesidibe
0
120
Android Development in 2019. #devFestDakar
soulesidibe
0
120
Android App Bundle
soulesidibe
0
97
Proguard: The open source optimizer for Java bytecode
soulesidibe
2
110
Kotlin why you should consider using it
soulesidibe
0
120
Lightning talk : La trousse du développeur android
soulesidibe
0
68
Other Decks in Programming
See All in Programming
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
SREは、MCPとSRE Agentをこう使え!
kazumax55
0
140
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
150
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
360k
Creating Composable Callables in Contemporary C++
rollbear
0
190
トークンをケチるな、設計しろ:GitHub Copilotを賢く使うコンテキスト戦略
ochtum
0
290
分散システム、なんですぐ死んでしまうん?耐障害性を高めたいあなたのためのレジリエンスパターン入門
mshibuya
7
2.7k
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
190
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
180
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
290
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
150
The Bowling Game- From Imperative to Functional Programming - Part 1
philipschwarz
PRO
0
260
Featured
See All Featured
Music & Morning Musume
bryan
47
7.3k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
260
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
72
40k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
380
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.8k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
230
Rails Girls Zürich Keynote
gr2m
96
14k
Into the Great Unknown - MozCon
thekraken
41
2.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
Transcript
Les AsyncTasks
Plan L’AsyncTask Les limites Android c’est du java non? La
solution magique Bonus
Un passionné d’android #nexus #startup #ios #java #play! #scala #ps3
#pes #techno #android #devops #BARCA #photos #google #api twitter: @soulesidibe gplus: plus.google.com/+souleymanesidibe
L’AsyncTask
• Traitement en background et mise a jour du UI
• Pas besoin de toucher aux Threads! AsyncTask.java
Pourquoi? AsyncTask.java
Pourquoi? • Ne pas bloquer le UI Thread! AsyncTask.java
Demo
Les limites
mAsync.cancel(true);
None
YourAsyncTask1 task1 = new YourAsyncTask1(); task1.execute(params); YourAsyncTask2 task2 = new
YourAsyncTask2(); task2.execute(params); Question: Serial or parallel?
Android c’est du java non?
Le framework Executor Executor executor = Executors.newSingleThreadExecutor(); executor.execute(new MyRunnable());
Le framework Executor Executor executor = Executors.newSingleThreadExecutor(); executor.execute(new MyRunnable()); ExecutorService
execute = Executors.newSingleThreadExecutor(); Future<Integer> future = execute.submit(new MonCallable());
Le framework Executor Executor executor = Executors.newSingleThreadExecutor(); executor.execute(new MyRunnable()); ExecutorService
execute = Executors.newSingleThreadExecutor(); Future<Integer> future = execute.submit(new MonCallable()); ScheduledExecutorService execute = Executors. newSingleThreadScheduledExecutor(); execute.scheduleAtFixedRate(new MonRunnable(), 0, 1, TimeUnit.SECONDS);
La solution magique
Fragment Activity
Fragment Activity Thread in progress
Fragment Activity Thread Done
Fragment Activity Thread Done BUS POST MyEvent
EventB MyEvent Thread Done BUS POST MyEvent MyEvent EventA EventB
EventA Subscribe Subscribe Subscribe
Event Bus Otto (goo.gl/sWxXY) EventBus (goo.gl/nAEW6) rxJava (goo.gl/TeWxWr)
Otto • Square (goo.gl/VlqRcA) • guava-based event bus • Open
Source • easy to use
Otto
Demo
Bonus
YourAsyncTask1 task1 = new YourAsyncTask1(); task1.executeOnExecutor(executor, params); YourAsyncTask2 task2 =
new YourAsyncTask2(); task2.executeOnExecutor(executor, params); Astuce
Communication entre Composants • Activity - Fragment • Fragment -
Fragment Otto, c’est doux!
Communication entre Composants Activity Fragment A Fragment B BUS
Links • #doc AsyncTask (goo.gl/MRbjQD) • #post The dark side
of AsyncTask (goo. gl/mm8IVR) • #tuto Le Framework Executor(goo. gl/MCJLq4) • #talk Android Bad Practices : comment foirer son app(goo.gl/Ix8Jsn)
MERCI!