how to avoid application not responding while net is disconnected in android
<p>i create login page . this login page validate from server database .if net is available mean if click login button means it works fine . if i disable net then click login button means it shows error the application was not responding .. how to avoid this error using my code</p>

<pre><code>      i try this code
          login.setOnClickListener(new View.OnClickListener()
    {

        public void onClick(View v)
        {
            name = username.getText().toString();
            pass = password.getText().toString();
            String Str_check2 = app_preferences.getString("checked", "no");
            if(Str_check2.equals("yes"))
            {
                SharedPreferences.Editor editor = app_preferences.edit();
                editor.putString("username", name);
                editor.putString("password", pass);
                 editor.commit();
            }
            if(name.equals("") || pass.equals(""))
            {
                 Toast.makeText(Main.this, "Please Enter Username and Password", Toast.LENGTH_LONG).show();
            }

            else

            try {
                httpclient = new DefaultHttpClient();
                httppost = new HttpPost("url/login.php");
                // Add your data
                nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2);
               nameValuePairs.add(new BasicNameValuePair("UserEmail", name.trim()));
                nameValuePairs.add(new BasicNameValuePair("Password", pass.trim()));
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                // Execute HTTP Post Request
                response = httpclient.execute(httppost);
                inputStream = response.getEntity().getContent();

                data = new byte[256];

                buffer = new StringBuffer();
                int len = 0;
                while (-1 != (len = inputStream.read(data)) )
                {
                    buffer.append(new String(data, 0, len));
                }

                inputStream.close();
            }

            catch (IOException e) {
                 System.out.println(e);

                 //alertDialog.cancel();

            }
            if(buffer.charAt(0)=='Y')
            {

                Intent intent=new Intent(getApplicationContext(),another.class);
                startActivity(intent);
            }
            else
            {
                 System.out.println("Invalid username and password")
            }         

        }
    });
</code></pre>
