Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have to put your code inside an <a href="http://developer.android.com/reference/android/os/AsyncTask.html" rel="nofollow">AsyncTask</a> , it is forbidden to download anything on the main UI thread since API 14 I believe.</p> <p>It would be something like this:</p> <pre><code>public class someTask extends AsyncTask&lt;String, Void, String&gt; { public MainActivity activity; public someTask(MainActivity a) { activity = a; } @Override protected String doInBackground(String... urls) { String stringtoparse=null; for (String url : urls) { stringtoparse= readMovieSchedules(url); // getting XML from URL } return stringtoparse; } @Override protected void onPreExecute(){ } @Override protected void onPostExecute(String readMovieSchedules) { // Hashmap for ListView ArrayList&lt;HashMap&lt;String, String&gt;&gt; movieList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); JSONArray jsonArray = new JSONArray(readMovieSchedules); Log.i(MainActivity.class.getName(), "Number of entries " + jsonArray.length()); for (int i = 0; i &lt; jsonArray.length(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); Log.i(MainActivity.class.getName(), jsonObject.getString("movie_name")); // Storing each json item in variable String name = jsonObject.getString(TAG_NAME); String type = jsonObject.getString(TAG_TYPE); String length = jsonObject.getString(TAG_LENGTH); String cinema = jsonObject.getString(TAG_CINEMA); String schedules = jsonObject.getString(TAG_SCHEDULES); String url = jsonObject.getString(TAG_URL); // creating new HashMap HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); // adding each child node to HashMap key =&gt; value map.put(TAG_NAME, name); map.put(TAG_TYPE, type); map.put(TAG_LENGTH, length); map.put(TAG_CINEMA, cinema); map.put(TAG_SCHEDULES, schedules); map.put(TAG_URL, url); // adding HashList to ArrayList movieList.add(map); } } </code></pre> <p>You have to modify the readMovieSchedules() to take the url as an argument like this readMovieSchedules(url) and I think it'll work just fine, you would call the task like this:</p> <pre><code>getMovieSched task = new someTask(MainActivity.this); task.execute(url); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload