App Freez and UI Blocking
<p>Hy!</p>

<p>I have 2 classes:</p>

<p>Main:</p>

<pre><code>    public class Main extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);
       startActivityForResult(new Intent(Main.this, Login.class), 1);

    }
}
</code></pre>

<p>LogIn:</p>

<pre><code>public class Login extends Activity{
    ProgressDialog pd = null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);

        final EditText user = (EditText)findViewById(R.id.login_etuser);
        final EditText pw = (EditText)findViewById(R.id.login_etpw);
        Button btlogin = (Button)findViewById(R.id.login_btlog);
        final Thread thread = new Thread (){
            public void run() {
                try
                {
                String result = "";
                result = postData(user.getText().toString(),pw.getText().toString());

                final JSONObject jObject = new JSONObject(result);
                JSONObject menuObject = jObject.getJSONObject("responseData");
                Log.e("XXX", menuObject.getString("session_id"));

                //pd.dismiss();
                }
                catch (Exception e)
                {
                    Log.e("XXX", e.getMessage());
                }



            };
        };

        btlogin.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                if (!user.getText().toString().equals("") &amp;&amp; !pw.getText().toString().equals(""))
                {

                    thread.run();

                }

            }
        });
    }
    public String postData(final String user, final String pw) {
        // Create a new HttpClient and Post Header
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://surfkid.redio.de/login");
        String result;
        BufferedReader in = null;

        try {
            // Add your data
            List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2);
            nameValuePairs.add(new BasicNameValuePair("username", user));
            nameValuePairs.add(new BasicNameValuePair("password", md5(pw)));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            // Execute HTTP Post Request
            HttpResponse response = httpclient.execute(httppost);
            if(response != null){
                in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

                StringBuffer sb = new StringBuffer("");
                String line = "";
                String NL = System.getProperty("line.separator");
                while ((line = in.readLine()) != null) {
                    sb.append(line + NL);
                }
                in.close();

                result = sb.toString();
                return result;
              }

        } catch (ClientProtocolException e) {
             Log.e("xxx", e.getMessage());
        } catch (IOException e) {
            Log.e("xxx", e.getMessage());
        }
        return null;
    }
     private String md5(String in) {

            MessageDigest digest;

            try {

                digest = MessageDigest.getInstance("MD5");

                digest.reset();        

                digest.update(in.getBytes());

                byte[] a = digest.digest();

                int len = a.length;

                StringBuilder sb = new StringBuilder(len &lt;&lt; 1);

                for (int i = 0; i &lt; len; i++) {

                    sb.append(Character.forDigit((a[i] &amp; 0xf0) &gt;&gt; 4, 16));

                    sb.append(Character.forDigit(a[i] &amp; 0x0f, 16));

                }

                return sb.toString();

            } catch (NoSuchAlgorithmException e) { e.printStackTrace(); }

            return null;

        }



}
</code></pre>

<p>Logcat:</p>

<pre><code>01-25 09:24:57.641: ERROR/AndroidRuntime(31148): FATAL EXCEPTION: main
01-25 09:24:57.641: ERROR/AndroidRuntime(31148): java.lang.NullPointerException: println needs a message
01-25 09:24:57.641: ERROR/AndroidRuntime(31148):     at android.util.Log.println_native(Native Method)
01-25 09:24:57.641: ERROR/AndroidRuntime(31148):     at android.util.Log.e(Log.java:215)
01-25 09:24:57.641: ERROR/AndroidRuntime(31148):     at android.skiptvad.Login$1.run(Login.java:59)
01-25 09:24:57.641: ERROR/AndroidRuntime(31148):     at android.skiptvad.Login$2.onClick(Login.java:75)
01-25 09:24:57.641: ERROR/AndroidRuntime(31148):     at android.view.View.performClick(View.java:2461)
01-25 09:24:57.641: ERROR/AndroidRuntime(31148):     at android.view.View$PerformClick.run(View.java:8888)
01-25 09:24:57.641: ERROR/AndroidRuntime(31148):     at android.os.Handler.handleCallback(Handler.java:587)
01-25 09:24:57.641: ERROR/AndroidRuntime(31148):     at android.os.Handler.dispatchMessage(Handler.java:92)
01-25 09:24:57.641: ERROR/AndroidRuntime(31148):     at android.os.Looper.loop(Looper.java:123)
01-25 09:24:57.641: ERROR/AndroidRuntime(31148):     at android.app.ActivityThread.main(ActivityThread.java:4627)
01-25 09:24:57.641: ERROR/AndroidRuntime(31148):     at java.lang.reflect.Method.invokeNative(Native Method)
01-25 09:24:57.641: ERROR/AndroidRuntime(31148):     at java.lang.reflect.Method.invoke(Method.java:521)
01-25 09:24:57.641: ERROR/AndroidRuntime(31148):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
01-25 09:24:57.641: ERROR/AndroidRuntime(31148):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-25 09:24:57.641: ERROR/AndroidRuntime(31148):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>Please Help!!!</p>

<p>What is wrong with the Thread.start in the Button on Click?</p>
