Thread exiting due uncaught exception
<p>Hy!</p>

<p>My code:</p>

<pre><code>Thread thread = new Thread (){
            @Override
            public void run() {
                while (true)
                {
                    Handler handler = new Handler(){
                          @Override
                          public void handleMessage(Message msg) {

                             if (msg.obj.toString()!= null)
                             {
                             JSONParse json = null;
                             try {
                                Log.e("Channel_State",msg.obj.toString());
                                 json = new JSONParse(msg.obj.toString());
                                String state = json.getChannelState();
                                id = state;
                                 TextView tv2 = (TextView)findViewById(R.id.mainscreen_state);
                                 tv2.setText("Channel State: "+ state);
                                Log.e("State",state);
                            } catch (final Exception e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                                runOnUiThread(new  Runnable() {
                                    public void run() {
                                        Toast toast ;
                                        toast =     Toast.makeText(getApplicationContext(), "Error" + e.getMessage(), 500);
                                        Log.e("Error",e.getMessage());
                                        toast.show();
                                    }
                                });
                            }

                             }
                             else
                             {

                               runOnUiThread(new  Runnable() {
                                public void run() {
                                    Toast toast ;
                                    toast =     Toast.makeText(getApplicationContext(), "error", 500);

                                    toast.show();
                                }
                            });
                             }
                          }
                          };

                    List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
                    params.add(new BasicNameValuePair("session_id", settings.getString("session_id","error")));
                    params.add(new BasicNameValuePair("channel_id",String.valueOf(settings.getInt("channel_id", -1))));
                    HttpConnection con = new HttpConnection(params, "http://surfkid.redio.de/getChannelImage", handler);
                    con.start();
                    try {
                        Log.e("Sleep","Begin");
                        this.sleep(5000);
                        Log.e("Sleep","End");

                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        Log.e("Sleep","Fail");
                    }

                }
            }
        };
        thread.start();
</code></pre>

<p>Log:</p>

<pre><code>02-10 00:01:29.044: ERROR/AndroidRuntime(1248): Uncaught handler: thread Thread-13 exiting due to uncaught exception
02-10 00:01:29.054: ERROR/AndroidRuntime(1248): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
02-10 00:01:29.054: ERROR/AndroidRuntime(1248):     at android.os.Handler.&lt;init&gt;(Handler.java:121)
02-10 00:01:29.054: ERROR/AndroidRuntime(1248):     at android.skiptvad.MainScreen$6$1.&lt;init&gt;(MainScreen.java:258)
02-10 00:01:29.054: ERROR/AndroidRuntime(1248):     at android.skiptvad.MainScreen$6.run(MainScreen.java:258)
</code></pre>

<p>Please help!</p>
