Hi In My After clicking the login button username and password after loading I need to clear the username and password.
And login it's moving to next activity but,clicking emulator back button dialogue is showing with loading symbol.
can any one help me.

**login**

```
 login.setOnClickListener(new OnClickListener() {
           @Override
           public void onClick(View v) {
              dialog = ProgressDialog.show(Login.this, "", 
                       "loading", true);  

             dialog.show();
               isInternetPresent = cd.isConnectingToInternet();
               if (!isInternetPresent) {
                   showAlertDialog(Login.this, "No Internet Connection",
                           "You don't have internet connection.", true);

                   return;

               }
               String username = usname.getText().toString();
               String password = pword.getText().toString();

               String name = user.get(SessionManager.KEY_USERNAME);

                   if (username.equals("")) {
                       Toast.makeText(Login.this, "ENTER USERNAME",
                               Toast.LENGTH_LONG).show();

                   }
                   if (password.equals("")) {
                       Toast.makeText(Login.this, "ENTER PASSWORD",
                               Toast.LENGTH_LONG).show();

                   }

              else if (!CheckUsername(username) && !CheckPassword(password)){
                       Toast.makeText(Login.this, "ENTER VALID USERNAME & PASSWORD",
                             Toast.LENGTH_LONG).show();
               }
               else{
                   queryString = "username=" + username + "&password="
                            + password ;
                  String usertype = DatabaseUtility.executeQueryPhp("usertype",queryString);
                  System.out.print(usertype);

            if(usertype.equalsIgnoreCase("Admin user Found")){
                runOnUiThread(new Runnable() {
                    public void run() {

                        Toast.makeText(Login.this, "Login Sucess",
                                   Toast.LENGTH_LONG).show();

                    }
                });
                dialog.dismiss();
                startActivity(new Intent(Login.this, Home.class));

            }
            else if(usertype.equalsIgnoreCase("Student User Found")){
                runOnUiThread(new Runnable() {
                    public void run() {
                        Toast.makeText(Login.this, "Login Sucess",
                                   Toast.LENGTH_LONG).show();

                    }
                });

                dialog.dismiss();
                Intent i = new Intent(Login.this, StudentPortal.class);

                i.putExtra("username",username);

            startActivity(i);
            }

            else if(usertype.equalsIgnoreCase("Teacher  user Found")){
                runOnUiThread(new Runnable() {
                    public void run() {
                        Toast.makeText(Login.this, "Login Sucess",
                                   Toast.LENGTH_LONG).show();

                    }
                });
                dialog.dismiss();
                startActivity(new Intent(Login.this, Home.class));
                finish();
            }
            else if(usertype.equalsIgnoreCase("No User Found")){
                runOnUiThread(new Runnable() {
                    public void run() {

                        tv1.setText("InValid UserName and Password");

                    }

                });
                        }

            }

           }

         });

       tv1.setText("");

    }

```