Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The reason why your application crashes on Android versions 3.0 and above, is because HoneyComb, Ice Cream Sandwich and JellyBean are much stricter about abuse against the UI Thread. For example, when an Android device running HoneyComb or above detects a network access on the UI thread, a NetworkOnMainThreadException will be thrown:</p> <pre><code>E/AndroidRuntime(673): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.ExampleActivity}: android.os.NetworkOnMainThreadException </code></pre> <p>The explanation as to why this occurs is well documented on the Android developer's site:</p> <pre><code>A NetworkOnMainThreadException is thrown when an application attempts to perform a networking operation on its main thread. This is only thrown for applications targeting the Honeycomb SDK or higher. Applications targeting earlier SDK versions are allowed to do networking on their main event loop threads, but it's heavily discouraged. </code></pre> <p>Some examples of other operations that ICS and HoneyComb won't allow you to perform on the UI thread are:</p> <ol> <li>Opening a Socket connection (i.e. new Socket()).</li> <li>HTTP requests (i.e. HTTPClient and HTTPUrlConnection).</li> <li>Attempting to connect to a remote MySQL database.</li> <li>Downloading a file (i.e. Downloader.downloadFile()).</li> </ol> <p>If you are attempting to perform any of these operations on the UI thread, you must wrap them in a worker thread. The easiest way to do this is to use of an AsyncTask, which allows you to perform asynchronous work on your user interface. An AsyncTask will perform the blocking operations in a worker thread and will publish the results on the UI thread, without requiring you to handle threads and/or handlers yourself.</p>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    1. 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