loadJSONArray immediately failing on Android build

edited November 2017 in Android Mode

Hi all! I am working on a little project which makes a request for a JSON array from an external server based on a lat/long pairing. The app compiles ok without errors, and runs ok on the device, but when I tap to make the request it immediately crashes.

I made a change to push the lat/long to the screen and that is functioning ok, and I am casting the lat/long to strings to construct the URL ok, but I am now just a bit stuck why it should just fall over when just trying to push the loadJSONArray request to a JSONArray var.

Any thoughts?



  • Answer ✓


    what happens if you have your .json in your app (or with an uri towards the sd card)??? if everything works that could mean that you must create a thread or an asyncTask for loading on line.

  • Hey @akenaton it seems that directly parsing the JSON works ok when I include it as a string. After looking around at asyncTask I understand that it would be more ideal for short processes, so will look at the thread route. Thanks for replying!

  • @precociousmouse===

    right, if download is a long process threading is better...

  • Will try and get round to making that change today, and will update the thread when it works

  • Thanks @akenaton for pointing me towards thread() - that did the trick and it's loading / parsing the json correctly now

Sign In or Register to comment.