Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Les AsyncTasks

Les AsyncTasks

Souleymane Sidibe

February 15, 2014
Tweet

More Decks by Souleymane Sidibe

Other Decks in Programming

Transcript

  1. 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
  2. • Traitement en background et mise a jour du UI

    • Pas besoin de toucher aux Threads! AsyncTask.java
  3. YourAsyncTask1 task1 = new YourAsyncTask1(); task1.execute(params); YourAsyncTask2 task2 = new

    YourAsyncTask2(); task2.execute(params); Question: Serial or parallel?
  4. Le framework Executor Executor executor = Executors.newSingleThreadExecutor(); executor.execute(new MyRunnable()); ExecutorService

    execute = Executors.newSingleThreadExecutor(); Future<Integer> future = execute.submit(new MonCallable());
  5. 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);
  6. YourAsyncTask1 task1 = new YourAsyncTask1(); task1.executeOnExecutor(executor, params); YourAsyncTask2 task2 =

    new YourAsyncTask2(); task2.executeOnExecutor(executor, params); Astuce
  7. 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)