download picture from dropbox and watch it in one activity in android -


i have 3 activities in android app. first 1 opens ssh connection , on raspberry pi different kind of things (running python scripts, uploading stuff dropbox etc). process takes 15-20 seconds , when ready, second activity comes click button downloads files, , then, on third activity can see files rpi made.

i want make the last 2 activity one, user not have click download or file. easiest way? can solve delays or threads or asynctask remains?

the file gets downloaded earlier in same activity placepic function , call it:

edit:

public class dropboxdownloader extends appcompatactivity implements view.onclicklistener {  string apta;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_pic_show);      strictmode.threadpolicy policy = new strictmode.threadpolicy.builder().permitall().build();     strictmode.setthreadpolicy(policy);      if (shouldaskpermissions()) {         askpermissions();     }      androidauthsession session = null;     try {         session = buildsession();     } catch (dropboxexception e) {         e.printstacktrace();     }     dropboxapi = new dropboxapi<>(session);     string[] fnames = null;     dropboxapi.entry dirent = null;     try {         dirent = dropboxapi.metadata("/", 1000, null, true, null);     } catch (dropboxexception e) {         e.printstacktrace();     }     arraylist<dropboxapi.entry> files = new arraylist<dropboxapi.entry>();     arraylist<string> dir = new arraylist<string>();       int = 0;     (dropboxapi.entry ent : dirent.contents) {         files.add(ent);// add list of thumbs can choose         //dir = new arraylist<string>();         dir.add(files.get(i++).path);     }      apta = "something";      dir.mkdirs();      final string dropboxdownloadpathto = path + apta.substring(0, 30);     final string dropboxdownloadpathfrom = apta;      toast.maketext(getapplicationcontext(), "download file ...", toast.length_short)             .show();      file file = new file(dropboxdownloadpathto + dropboxdownloadpathfrom             .substring(dropboxdownloadpathfrom.lastindexof('.')));     if (file.exists()) file.delete();     try {         fileoutputstream outputstream = new fileoutputstream(file);         dropboxdownloader.dropboxapi.getfile(dropboxdownloadpathfrom, null,                 outputstream, null);     } catch (filenotfoundexception e) {         e.printstacktrace();     } catch (dropboxexception e) {         toast.maketext(this, "ez hiba: " + e, toast.length_short).show();     }      placepic(); }   public void placepic() {      backtomenu = (button) findviewbyid(r.id.button6);     backtomenu.setonclicklistener(this);     gotomypics = (button) findviewbyid(r.id.button5);     gotomypics.setonclicklistener(this);     string this_pic = environment.getexternalstoragedirectory()             .getabsolutepath() + "/aha" + apta;     toast.maketext(this, "this_pic: " + this_pic, toast.length_long).show();     file f = new file(this_pic);     if (f.exists() && !f.isdirectory()) {         toast.maketext(this, "delay begins", toast.length_short).show();         final handler handler = new handler();         handler.postdelayed(new runnable() {             @override             public void run() {                 toast.maketext(dropboxdownloader.this, "delayed?", toast                         .length_short).show();                  if (apta.startswith("/pi_pic_lc")) {                     string dedo = environment.getexternalstoragedirectory().getabsolutepath() +                             "/aha/" +                             apta;                     toast.maketext(dropboxdownloader.this, "open this: " + dedo, toast                             .length_short).show();                      try {                         ali.setimageuri(uri.parse(dedo));                      } catch (exception e) {                         toast.maketext(dropboxdownloader.this, "error: " + e, toast.length_short)                                 .show();                     }                 } else {                     string kutya = environment.getexternalstoragedirectory().getabsolutepath() +                             "/aha/"                             + apta;                       toast.maketext(dropboxdownloader.this, "open this: " + kutya, toast                             .length_short).show();                     try {                         ali.setimageuri(uri.parse(kutya));                         photoviewattacher pv = new photoviewattacher(ali);                      } catch (exception e) {                         toast.maketext(dropboxdownloader.this, "error: " + e, toast.length_short)                                 .show();                     }                 }             }         }, 5000);      } else {         toast.maketext(this, "cant file", toast.length_short).show();     }   } } 

thanks in advance!


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -