android - downloading terminates when App goes to background -


i working on app, uses phonegap.

when app started first time, downloading data server. downloading process being executed in asynctask, , in onpostexecute() of that, loading url.

the problem being arose that, when download process getting executed, , app somehow goes background, downloading gets terminated, unfortunately, absolutely not required.

to overcome trouble; guess, using service 1 of options. but, in case, question arises, is, how can possibly, load url inside service.

otherwise, else can done?

please, suggest me possible ways rid off trouble, facing.

use similar method downloading data. may helpful.

     public void downloadusingget(string apkurl, string filename) {          try {             string path = environment.getexternalstoragedirectory()+"/android/data/"+getpackagename()+"/files/";             url url = new url(apkurl);             httpurlconnection c = (httpurlconnection) url.openconnection();             c.setrequestmethod("get");             c.connect();             file file = new file(path);             file.mkdirs();             file outputfile = new file(file, filename);             fileoutputstream fos = new fileoutputstream(outputfile);              inputstream = c.getinputstream();              byte[] buffer = new byte[1024];             int len1 = 0;             while ((len1 = is.read(buffer)) != -1) {                 fos.write(buffer, 0, len1);             }             fos.close();             is.close();          } catch (ioexception e) {          }        } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -