android - Interrupt a specific Thread launched from IntentService -


i'm trying download multiple files server device.

here i've done:

on activities

... intent intent = new intent(this, downloadservice.class); intent.putextra(downloadservice.url, url); startservice(intent); 

downloadservice class

public class downloadservice extends intentservice { ...     @override     protected void onhandleintent(final intent intent) {         new thread(new runnable() {         @override         public void run() {             // download code...         }     }).start(); } 

my intentservice can launched multiple times activity (for example want download file0, file1, ..., filen): that's why use thread inside onhandleintent, in order download them separately.

and here problem: how can cancel / interrupt download of specific thread, launched intentservice? there no ui update during download, notification progress bar, of course updated thread.

a file's size can of 1gb , i'm trying undo download.

edit 1 :

downloadmanager useful, know, file composed multiple sub-files, created 1 one server @ runtime. i've tried way, not i'm looking for.

finally managed solve problem.

as suggested @commonsware (thanks again!) created service instead of intentservice , manage multiple threads threadpoolexecutor in specific class called each time onstartcommand.

long story short: followed this google guide , got inspired threadsample project.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -