Connection Time out when connecting to server from android device
<p>I am trying to connect from my android phone to my server. But I got time-out connection error. 
what can be the the cause?</p>

<p>my code is </p>

<pre><code>public void onClick(View view) {
    if (view == loginBtn) {
        if (username.getText().length() != 0 &amp; password.getText().length() != 0) {

            progressDialog = ProgressDialog.show(this,Farsi.Convert(""),"Verifying user credential"); 

            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        Connection connection = getConnection();
                        User user = connection.login(username.getText().toString(), password.getText().toString()); 
                        if (user != null) {
                            BaseKaizenActivity.getStorageManager().setUser(user);
                            Log.d("---", user.getId() + "  :  " + user.getName());
                            showActivity(MainMenuActivity.class);
                        }
                        else {
                            handleException("Invalid username or password");
                        }
                    }
                    catch (Exception exc) {
                        handleException(exc.getMessage());
                    }
                    finally {
                        if (progressDialog != null) {
                            progressDialog.dismiss();
                        }
                    }
                }
            });
            thread.start();
        }
        else {
            handleException("Insert username and password");
        }
    }
}
</code></pre>

<p>The exception I got is </p>

<pre><code>Connect to /10.0.2.2:8080 timed out
org.apache.http.conn.ConnectTimeoutException: Connect to /10.0.2.2:8080 timed out
at     org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:121)
at     org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(
       DefaultClientConnectionOperator.java:156)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
at     org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:428)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
at com.pda.kaizen.ConnectionImpl.executeHttpPost(ConnectionImpl.java:133)
at com.pda.kaizen.ConnectionImpl.login(ConnectionImpl.java:88)
at com.pda.kaizen.activity.LoginActivity$1.run(LoginActivity.java:98)
at java.lang.Thread.run(Thread.java:1019)
</code></pre>
