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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Souleymane Sidibe
February 15, 2014
Programming
75
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
190
Code sharing with Kotlin multi-platform
soulesidibe
0
120
Android Development in 2019. #devFestDakar
soulesidibe
0
120
Android App Bundle
soulesidibe
0
100
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
71
Other Decks in Programming
See All in Programming
信頼性の目標を誰も求めてない
shubox
0
490
異なる設計思想のフレームワークを経験して得た学び
amekuhideki
2
1.5k
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
600
MIZARU@SPAJAM2026 第二回予選
1901drama
0
110
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
200
ソフトウェアラスタライザ
fadis
1
790
Building an Out-of-Order CPU
latte72
1
710
自分的「カンファレンスの楽しみ方」
syumai
0
190
Oxlintはいいぞ(続)
yug1224
1
550
iOS開発×AI駆動開発 〜最近使って便利だったスキルの話〜
nogu66
0
140
新卒PdEのリアル
ryu1013
1
420
初めての模倣学習とVLA
natsutan
0
500
Featured
See All Featured
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
690
Prompt Engineering for Job Search
mfonobong
0
440
How to build a perfect <img>
jonoalderson
1
6k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Code Reviewing Like a Champion
maltzj
528
40k
We Are The Robots
honzajavorek
0
350
AI: The stuff that nobody shows you
jnunemaker
PRO
9
980
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
890
The Mindset for Success: Future Career Progression
greggifford
PRO
0
490
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
230
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
320
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!