Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to get text from an url with AsyncTask and Jsoup but the text doesn't show
    text
    copied!<p>The urls are just text files like www.example.com/example.txt so what I need to do is get the whole text from the website. The text can be very long up to 1MB. I don't know why my code does not work. When I run the code progress dialog shows up and goes away but the text is not loaded and I am not getting any errors.</p> <p>Here is part of my code</p> <pre><code> public class Story extends Activity { Elements elem = null; Document document; String url = "http://www.example.com/example.txt"; ProgressDialog progressDialog; private class Title extends AsyncTask&lt;Void, Void, Void&gt; { @Override protected void onPreExecute() { super.onPreExecute(); progressDialog = new ProgressDialog(Story.this); progressDialog.setMessage("Loading"); progressDialog.setIndeterminate(false); progressDialog.setCancelable(false); progressDialog.show(); } @Override protected Void doInBackground(Void... params) { try { document = Jsoup.connect(url).get(); } catch (IOException e) { e.printStackTrace(); } elem = document.select("*"); return null; } @Override protected void onPostExecute(Void result) { for (Element element : elem){ String valueofelement = element.text(); story.add(valueofelement); //story is an a progressDialog.dismiss(); } } } </code></pre> <p>I call it with <code>new Title().execute();</code></p> <p>Here is the LogCat</p> <pre><code> 11-29 17:13:07.563: D/KenBurnsView(15380): swapImage active=0 11-29 17:13:07.563: D/KenBurnsView(15380): new active=1 11-29 17:13:07.568: D/KenBurnsView(15380): starting Ken Burns animation android.view.ViewPropertyAnimator@42d5bfb8 11-29 17:13:18.103: D/AbsListView(18123): Get MotionRecognitionManager 11-29 17:13:18.178: D/dalvikvm(18123): GC_FOR_ALLOC freed 51K, 9% free 12366K/13447K, paused 22ms, total 22ms 11-29 17:13:18.183: I/dalvikvm-heap(18123): Grow heap (frag case) to 13.915MB for 971248-byte allocation 11-29 17:13:18.208: D/dalvikvm(18123): GC_CONCURRENT freed 2K, 8% free 13312K/14407K, paused 12ms+1ms, total 24ms 11-29 17:13:18.233: D/dalvikvm(18123): GC_FOR_ALLOC freed &lt;1K, 8% free 13313K/14407K, paused 15ms, total 15ms 11-29 17:13:18.243: I/dalvikvm-heap(18123): Grow heap (frag case) to 15.540MB for 1705616-byte allocation 11-29 17:13:18.268: D/dalvikvm(18123): GC_CONCURRENT freed &lt;1K, 8% free 14978K/16135K, paused 19ms+1ms, total 28ms 11-29 17:13:18.608: D/libEGL(18123): loaded /system/lib/egl/libEGL_mali.so 11-29 17:13:18.638: D/libEGL(18123): loaded /system/lib/egl/libGLESv1_CM_mali.so 11-29 17:13:18.643: D/libEGL(18123): loaded /system/lib/egl/libGLESv2_mali.so 11-29 17:13:18.663: D/(18123): Device driver API match 11-29 17:13:18.663: D/(18123): Device driver API version: 10 11-29 17:13:18.663: D/(18123): User space API version: 10 11-29 17:13:18.663: D/(18123): mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Tue Oct 16 15:37:13 KST 2012 11-29 17:13:18.698: D/OpenGLRenderer(18123): Enabling debug mode 0 11-29 17:13:18.953: D/KenBurnsView(18123): swapImage active=-1 11-29 17:13:19.003: D/KenBurnsView(18123): starting Ken Burns animation android.view.ViewPropertyAnimator@42d5e370 11-29 17:13:19.503: D/dalvikvm(18123): GC_CONCURRENT freed 580K, 10% free 15325K/16903K, paused 88ms+1ms, total 115ms 11-29 17:13:22.583: W/IInputConnectionWrapper(18123): getSelectedText on inactive InputConnection 11-29 17:13:22.588: W/IInputConnectionWrapper(18123): setComposingText on inactive InputConnection 11-29 17:13:22.623: W/IInputConnectionWrapper(18123): getExtractedText on inactive InputConnection 11-29 17:13:28.203: D/KenBurnsView(18123): swapImage active=1 11-29 17:13:28.203: D/KenBurnsView(18123): new active=0 11-29 17:13:28.208: D/KenBurnsView(18123): starting Ken Burns animation android.view.ViewPropertyAnimator@42e55930 11-29 17:13:37.433: D/KenBurnsView(18123): swapImage active=0 11-29 17:13:37.433: D/KenBurnsView(18123): new active=1 11-29 17:13:37.788: D/KenBurnsView(18123): starting Ken Burns animation android.view.ViewPropertyAnimator@42d5e370 </code></pre>
 

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