Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 0    Views: 92

cpmilez
Aspiring developer
Profile
Posts: 63
Reg: Jan 03, 2012
Ipswich, UK
6,030
03/04/14 03:23 AM (10 years ago)

Quiz - Android - Send Results to URL Bug.

There seems to be a bug in the Quiz plugin on Android where the quiz results fail to send. I thought i'd found the issue to start with as I found the code was trying to post to the BT dataURL instead of the sendResultsToURL. I fixed this firstly in the sendQuizResultsToURL method. (This needs to be fixed in the plugin). //useURL = BT_strings.mergeBTVariablesInString(dataURL); useURL = BT_strings.mergeBTVariablesInString(useURL); However there is still an issue with it sending the request. The error shown in logcat is: BT_downloader:downloadTextData from URL EXCEPTION: android.os.NetworkOnMainThreadException... followed by the URL. I know the URL is good and have tested this ok in my browser. I have checked the access log and can see no requests. I looked online for a solution to the android except and landed here: http://stackoverflow.com/questions/6343166/android-os-networkonmainthreadexception It seems the correct way to fix this is to use the AsyncTask code, however I am unsure of how to implement this. I tested using the other solution regarding thread policy. By adding these two lines of code to BT_downloader.downloadTextData. StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); This fixed the issue and the URL is now called at the end of the quiz. My problem is this solution is not advised and really the correct fix is to use the AsyncTask code AFAICT. Strange that the other http requests are not effected for loading the json data for the app and quiz questions, but I guess it depends on where in the code it's called. Can anyone advise on my findings and if i'm on the right lines? I guess if AsyncTask is needed then the BT_downloader class should be modified by BT. Thanks Chris
 

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.