android - ftp file download result in black screen -


i downloading file ftp server. downloading code worked fine, after download code screen doesn't show ,it gets black. download function not returning true value, file being saved in specified directory.

  public class ftpclass{   protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_file_player);                  strictmode.threadpolicy policy = new strictmode.threadpolicy.builder().permitall().build();     strictmode.setthreadpolicy(policy);      intent intent = getintent();     dirname = intent.getstringextra("currentdirname");       myftpclient mftp = new myftpclient();     createpath = mftp.getapprootpath().concat("/"+ dirname);     mftp.setcurrentdir(createpath);     system.out.println(mftp.ftpchangedirectory(createpath));      ftpfile[] farr = mftp.ftplistallfiles();     system.out.println(farr.length);      for(int = 0; i<farr.length;i++){         system.out.println("src: "+createpath+"/"+farr[i].getname());          string src = createpath+"/"+farr[i].getname();         system.out.println("dest: "+"/data/data/com.example.ftpplayer" + "/app_"+dirname);         string dest ="/data/data/com.example.ftpplayer" + "/app_"+dirname+"/"+farr[i].getname();         system.out.println(mftp.downloadfile(src,dest));     } } }  public class callingintent extends activity{         system.out.println("in item click ");             intent intent = new intent(getapplicationcontext(), ftpclass.class);             string dir = ((textview) view).gettext().tostring();             intent.putextra("currentdirname", dir);             startactivity(intent);  }  public class myftpclient{   public boolean downloadfile(string srcpath , string destpath){      try {         fileoutputstream fos = new fileoutputstream(destpath);         system.out.println(mftp.retrievefile(srcpath, fos)); // retrieve file doesn't return true         fos.flush();         fos.close();         return true;     } catch (filenotfoundexception e) {         e.printstacktrace();     }catch(ioexception e){         e.printstacktrace();     }     return false; }  } 

you need run code on background thread, try using asynctask.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -