Note that there are some explanatory texts on larger screens.

plurals
  1. POAsyncTask and JSOUP playing nicely together
    primarykey
    data
    text
    <p>I've been working on a personal bar taplist which parses a webpage using JSOUP for listed beers and, more importantly here, the last change date. The problem here is that when I load the activity, the parsed content does not appear until I manually intervene and hold my finger over a button leading to another activity. Within my "public class MainScreen..." my relevant code looks like this:</p> <pre><code> public class MainScreen extends ExpandableListActivity implements OnChildClickListener { ArrayList&lt;String&gt; mData = new ArrayList&lt;String&gt;(); ListView mListView; ArrayAdapter&lt;String&gt; mAdapter; ArrayList&lt;String&gt; ArrayOfBeerNames; ArrayList&lt;Beer&gt; ArrayOfBeers; ExpandableListView expandbleLis; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.taplist); expandbleLis = getExpandableListView(); expandbleLis.setDividerHeight(2); expandbleLis.setGroupIndicator(null); expandbleLis.setClickable(true); ArrayOfBeerNames = new ArrayList&lt;String&gt;(); ArrayOfBeers = new ArrayList&lt;Beer&gt;(); new AsyncDerp().execute(); } private class AsyncDerp extends AsyncTask&lt;Void, Void, Void&gt; { private ProgressDialog LoginProgressDialog = new ProgressDialog(MainScreen.this); protected void onPreExecute() { LoginProgressDialog.setMessage("Fetching the up-to-date list..."); LoginProgressDialog.show(); } @Override protected Void doInBackground(Void... params) { processUpdate(); return null; } private void processUpdate() { String URL = "http://www.dogfish.com/restaurant/menus/brews-whats-on-tap.htm"; try { Document doc = Jsoup.connect(URL) .userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0") .get(); Elements updates = doc.select("p:matches(.+?)+p"); for(Element update: updates) { String TheUpdateTextWeGot = update.text(); if((TheUpdateTextWeGot.contains("updated"))) { String updatedate = "Current as of " + TheUpdateTextWeGot.substring(9, 20) + "."; TextView tv = (TextView)findViewById(R.id.tv); tv.setText(updatedate); } } if(mData.size() == 0) { mData.add("Empty result"); } } catch (Exception ex) { ex.printStackTrace(); mData.clear(); mData.add("Exception: " + ex.toString()); } } protected void onPostExecute(Void unused) { LoginProgressDialog.dismiss(); } } </code></pre> <p>I realize that there are a few things going on here as many SE posts have reminded me. It is using Async to download the page and parse it but the app should be displaying the data automatically too without me having to intervene and force it to do so.</p> <p>Where am I going wrong here? </p> <p>Many thanks.</p>
    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.
 

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