android - How to Confirm that Child Activity has been finished before starting that child again? -


i have parent activity has 2 childs activities b , c. when open parent activity decides child activity have open. (function using startactivityforresult) eg. decide open b. b plays video , return result back. thats fine next if decide open b again. b not opening fine (not playing video).

note: following fine:

a-->b , a<--b

then

a-->c , a<--c

then

a-->b , a<--b

but following not working:

a-->b , a<--b

then

a-->b , a<--b //when try move again on b. think calling b again before finished

then

a-->c , a<--c

any idea solve problem??

mean how can child activity has beed finished before calling child again??

following code of parent activity:

@override     protected void onactivityresult(int requestcode, int resultcode, intent data) {         super.onactivityresult(requestcode, resultcode, data);         log.d(constants.tag,"requestcode: "+requestcode+" : resultcode : "+ resultcode);         finishactivity(requestcode);         playprogram(requestcode);     }      private void playprogram(int requestcode){         if(requestcode == question_wrapper){             currentchap = currentchap + 1;             intent intent = new intent(moviewrapperactivity.this, videowrapperactivity.class);             intent.putextra("chaptertoplay", currentchap);             intent.putextra("videofile",  constants.mcourse.getmchapters().get(currentchap).getvideourl());             startactivityforresult(intent, movie_wrapper);         }else if(requestcode == movie_wrapper) {             if(constants.mcourse.getmchapters().get(currentchap).isquiz()){                 intent in2 = new intent(moviewrapperactivity.this, questionwrapper.class);                 in2.putextra("chaptertoplay", currentchap);                 startactivityforresult(in2, question_wrapper);              }else{                 currentchap = currentchap + 1;                 intent intent = new intent(moviewrapperactivity.this, videowrapperactivity.class);                 intent.putextra("chaptertoplay", currentchap);                 intent.putextra("videofile",  constants.mcourse.getmchapters().get(currentchap).getvideourl());                 startactivityforresult(intent, movie_wrapper);             }         }     } 

code of b:

protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     if (!io.vov.vitamio.libschecker.checkvitamiolibs(this))         return;     setcontentview(r.layout.videoview);     init();     mvideoview = (videoview) findviewbyid(r.id.surface_view);     mvideoview.setvideopath(videopath);     mvideoview.setvideoquality(mediaplayer.videoquality_high);     mcontroller = new mediacontroller(this);     mvideoview.setmediacontroller(mcontroller);     mvideoview.setoncompletionlistener(new oncompletionlistener() {          @override         public void oncompletion(mediaplayer arg0) {             log.d(constants.tag,"completed");             intent returnintent = new intent();             setresult(result_ok, returnintent);             mvideoview = null;             mcontroller = null;             finish();         }     }); } 

i think media elements in b taking time destroy or not being destroyed.

intent output = new intent();     output.putextra("data", data);     setresult(activity.result_ok  , output);     finish(); 

just call finish() after setting result.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -