Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 6    Views: 79

mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
12/01/15 10:09 AM (8 years ago)

Quiz Plugins -> Android Hibernation Restarts Quiz.. How do i avoid that?

The resume function doesn't work for me. When testing, I play for about 10 seconds and put the phone into lock or hibernate the quiz does not resume where it started, it starts completely over. I could really care less lol, but Amazon require that it does resume :/ I never had this issue with the BT 2.0 Android this occurs in BT 3.0.. Any workarounds?! Thanks
 
krompa
Lost but trying
Profile
Posts: 257
Reg: Jun 14, 2013
Bristol
8,820
like
12/01/15 10:25 AM (8 years ago)
Yes. I have a solution. I'll send through when I'm back home (in about 4 hrs). If u want an immediate solution then look at the difference in the code at onStart, onPause, Onresume and onStop between v2.0 and 3.0 in the screen quiz java file. From memory it's only a couple of lines.
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
12/01/15 10:27 AM (8 years ago)
Thanks a lot. I'll check out the v2.0 and update here if or not I figure it out!
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
12/01/15 10:40 AM (8 years ago)
Got it :) The start and pause code was reversed and some other code. I appreciate the response!
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
12/01/15 03:27 PM (8 years ago)
Would be great if there are some more details to share for the non coders please.
 
krompa
Lost but trying
Profile
Posts: 257
Reg: Jun 14, 2013
Bristol
8,820
like
12/01/15 04:05 PM (8 years ago)
MySps - On return to the quiz, the quiz sounds won't work. In order to get these working, I think I commented out //killQuizSounds(); in the onPause method. Alan - I think I have made other changes to the 3.0 app code for other purposes, so this code comes with a health warning. Save your old code just in case it doesn't work. // add this line within - public class BT_screen_quiz extends BT_fragment private boolean didLoadData = false; // replace your onStop, onResume, onPause and onStop with this: //onStart... @Override public void onStart() { BT_debugger.showIt(fragmentName + ":onStart"); super.onStart(); } //onResume... @Override public void onResume() { BT_debugger.showIt(fragmentName + ":onResume"); super.onResume(); if(!didLoadData){ //String dataURL1 = dataURL + ".txt"; if(saveAsFileName.length() > 1){ //check cache... String parseData = ""; if(BT_fileManager.doesCachedFileExist(saveAsFileName)){ BT_debugger.showIt(fragmentName + ":onStart using cached screen data"); parseData = BT_fileManager.readTextFileFromCache(saveAsFileName); parseScreenData(parseData); }else{ //get data from URL if we have one... if(this.dataURL.length() > 1){ BT_debugger.showIt(fragmentName + ":onStart downloading screen data from URL"); refreshScreenData(); }else{ //parse with "empty" data... BT_debugger.showIt(fragmentName + ":onStart using data from app's configuration file"); parseScreenData(""); } } }//saveAsFileName }//did load data } //onPause @Override public void onPause() { super.onPause(); BT_debugger.showIt(fragmentName + ":onPause"); //kill possible sound effect players... //killQuizSounds(); } //onStop @Override public void onStop(){ super.onStop(); //BT_debugger.showIt(fragmentName + ":onStop"); if(downloadScreenDataWorker != null){ boolean retry = true; downloadScreenDataWorker.setThreadRunning(false); while(retry){ try{ downloadScreenDataWorker.join(); retry = false; }catch (Exception je){ } } } //kill timer for countdown timer... if(updateCountdownHandler != null){ updateCountdownHandler.removeCallbacks(mUpdateCountdownTask); } //kill timer for running quiz timer... if(updateTimeHandler != null){ updateTimeHandler.removeCallbacks(mUpdateTimeTask); } if(delayHandler != null){ delayHandler.removeCallbacks(mDelayTask); } //kill possible sound effect players... killQuizSounds(); }//onStop...
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
12/01/15 06:28 PM (8 years ago)
@Alanmac Add this as well under the class to prevent error: private boolean didLoadData = false; and search for: //parse screenData... Paste this: //flag data loaded... didLoadData = true; Above: //hide progress... hideProgress();
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.