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
霧の中の代数的エフェクト
funnyycat
1
140
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
470
act1-costs.pdf
sumedhbala
0
160
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
350
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
1k
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
340
任せる範囲はこう広がった / How the Scope of AI Delegation Has Expanded
nrslib
1
230
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
自作OSでスライド発表する
uyuki234
1
3.6k
ローカルLLMでどこまでコードが書けるか -縮小版 / How much code can be written on a local LLM Shortened
kishida
2
170
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
250
エンジニアにデザインハーネスを 〜デザインプロセスを規定するためのハーネス〜 / Design harness from an engineer's perspective
rkaga
2
660
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
250
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.1k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
670
30 Presentation Tips
portentint
PRO
1
340
Faster Mobile Websites
deanohume
310
32k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2k
The Cost Of JavaScript in 2023
addyosmani
55
10k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
280
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.6k
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!