Android - setSupportProgressBarIndeterminateVisibility(true) not working
<p>I am using <code>supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS)</code> and to show or hide the ProgressBar, I am using <code>setSupportProgressBarIndeterminateVisibility()</code>.
<br>
The motive being that, the email address is sent to server once it is validated and meanwhile the response from the server is awaited and the ProgressBar is shown. On getting the response, the ProgressBar is hidden.
<br>
My code should have worked. Kindly have a look below.
<br></p>

<pre><code>public class LoginActivity extends ActionBarActivity {

String response = "";
String emailAddress, Password;
EditText email, password;
Button sign_in;
TextView register, forgotPassword;

@Override
protected void onCreate(Bundle savedInstanceState) {
    supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    sign_in = (Button) findViewById(R.id.sign_in);
    register = (TextView) findViewById(R.id.register);
    forgotPassword = (TextView) findViewById(R.id.forgotPassword);


    register.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
            startActivity(intent);
        }
    });

    sign_in.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            email = (EditText) findViewById(R.id.email);
            password = (EditText) findViewById(R.id.password);
            emailAddress = email.getText().toString();
            Password = password.getText().toString();

            if (!emailAddress.equals("") &amp;&amp; !Password.equals("")){
                setSupportProgressBarIndeterminateVisibility(true);
                    try {
                        response = new Connection().execute().get().toString();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    } catch (ExecutionException e) {
                        e.printStackTrace();
                    }

                if (response.equals("Credentials Validated!")) {
                    setSupportProgressBarIndeterminateVisibility(false);
                    Toast.makeText(LoginActivity.this, response, Toast.LENGTH_SHORT).show();
                    Intent intent = new Intent(LoginActivity.this, Home.class);
                    intent.putExtra("emailAddress", emailAddress);
                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                    finish();
                    startActivity(intent);
                } else {
                    setSupportProgressBarIndeterminateVisibility(false);
                    final AlertDialog alertDialog = new AlertDialog.Builder(
                            LoginActivity.this).create();

                    // Setting Dialog Title
                    alertDialog.setTitle("We need your attention!");

                    // Setting Dialog Message
                    alertDialog.setMessage(response);

                    // Setting Icon to Dialog
                    alertDialog.setIcon(R.drawable.ic_launcher);

                    // Setting OK Button
                    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            // Write your code here to execute after dialog closed
                            alertDialog.cancel();
                        }
                    });

                    // Showing Alert Message
                    alertDialog.show();
                }
            }
            else {
                if(emailAddress.equals("")) {
                    email.setError("Email Address Cannot Be Empty!");
                }
                else
                    if(Password.equals("")){
                        password.setError("Password Cannot Be Empty!");
                    }
            }
        }
    });


}


private class Connection extends AsyncTask {
    @Override
    protected String doInBackground(Object[] objects) {
        LoginJSONParser loginJsonParser = new LoginJSONParser();
        return loginJsonParser.getJson(emailAddress, Password);
    }
}
</code></pre>

<p>}</p>