android Asynctask call method in Activity -


i downloading video ftp-server via asynctask , save on device. after download (onpostexecute) want play video directly in videoview in activity, problem can't call playvideo method since not static , instead have tried call in onresume() method, get() method, progressbar in asynctask doesn't show , app later crashes. suggestion?

thank in advance

public class playstreamedvideo extends activity {

final string tag = "playstreamedvideo"; private videoview videoview; private mediacontroller mediacontroller; private downloadvideo download;  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      setcontentview(r.layout.guessvideo);     setrequestedorientation(activityinfo.screen_orientation_portrait);      download = new downloadvideo(playstreamedvideo.this, save_path);     download.execute();  }     @override     protected void onresume(){         try {             while(download.get() == false){                 log.d(tag, "1");             }             playvideo();         } catch (interruptedexception e) {             // todo auto-generated catch block             e.printstacktrace();         } catch (executionexception e) {             // todo auto-generated catch block             e.printstacktrace();         }         super.onresume();        }  public void playvideo() {     try {         videoview = (videoview) findviewbyid(r.id.streamedvideosurface);         mediacontroller = new mediacontroller(this);         videoview.setvideouri(uri.parse(save_path));         videoview.setmediacontroller(mediacontroller);         videoview.start();     } catch (exception e) {         // log.e(tag, "error: " + e.getmessage(), e);     } } 

i think easier declare videoview member of playstreamedvideo class. put declarations oncreate():

    videoview = (videoview) findviewbyid(r.id.streamedvideosurface);     mediacontroller = new mediacontroller(this);     videoview.setmediacontroller(mediacontroller); 

then call onpostexecute():

    videoview.setvideouri(uri.parse(save_path));     videoview.start(); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -