Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have a </p> <pre><code>android.os.NetworkOnMainThreadException </code></pre> <p>Which has nothing to do with your jar working properly or not.</p> <p>The Exception is thrown by the new versions of Android so that you don't lock the UI Thread (which is the main Thread) doing network operations.</p> <p>Use an <a href="http://developer.android.com/reference/android/os/AsyncTask.html">AsyncTask</a> (simple explanation about what each part of the AsyncTask does can be found <a href="http://androidresearch.wordpress.com/2012/03/17/understanding-asynctask-once-and-forever/">here</a>)or another <a href="http://developer.android.com/reference/java/lang/Thread.html">Thread</a> for network stuff. An Asynctask is easier to work with if you need to update the UI once the background work completes.</p> <p>An example of an AsyncTask with your code base can be:</p> <pre><code>private class MyTask extends AsyncTask&lt;Void, Void, String&gt; { @Override protected String doInBackground(Void... params) { String title =""; Document doc; try { doc = Jsoup.connect("http://google.com/").get(); title = doc.title(); System.out.print(title); } catch (IOException e) { e.printStackTrace(); } return title; } @Override protected void onPostExecute(String result) { //if you had a ui element, you could display the title ((TextView)findViewById (R.id.myTextView)).setText (result); } } </code></pre> <p>I assume: </p> <ul> <li>The task is an <strong>inner</strong> class in your Activity.</li> <li>You are forwarding the title gotten to a UI Element (eg a <code>TextView</code>) since that's what AsyncTasks are usually used for.</li> </ul> <p>To call the AsyncTask, put this after <code>setContentView(R.layout.activity_main);</code></p> <pre><code>new MyTask().execute(); </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.
    3. 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