@Override
    protected String doInBackground(String... strings) {
      String status = "";
      String stringURL = Constant.hostURL + Constant.loginMethod;
      Log.d("QUYYYY1111", "Login url: " + stringURL);
      Log.d("QUYYYY1111", "Login param: " + strings[0] + "-" + HSTSUtils.encryptMD5(strings[1]));

      try {
        URL url = new URL(stringURL);
        HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
        urlConnection.setReadTimeout(100000);
        urlConnection.setConnectTimeout(30000);
        urlConnection.setRequestMethod("POST");
        urlConnection.setDoInput(true);
        urlConnection.setDoOutput(true);

        List<NameValuePair> params = new ArrayList<NameValuePair>();
        Constant.username = strings[0];
        params.add(new BasicNameValuePair("username", strings[0]));
        params.add(new BasicNameValuePair("password", HSTSUtils.encryptMD5(strings[1])));

        OutputStream os = urlConnection.getOutputStream();
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
        writer.write(HSTSUtils.getQuery(params));
        writer.flush();
        writer.close();
        os.close();

        urlConnection.connect();

        InputStream inStream = urlConnection.getInputStream();
        BufferedReader bReader = new BufferedReader(new InputStreamReader(inStream));
        String temp, response = "";
        while ((temp = bReader.readLine()) != null) {
          response += temp;
        }
        Log.d("QUYYY111", "Response: --" + response);
        try {
          JSONObject patientObject = new JSONObject(response);
          Constant.accountId = patientObject.getString("accountId");
          Constant.PATIENT_NAME = patientObject.getString("fullname");
          Constant.patientId = patientObject.getString("patientId");
          status = patientObject.getString("status");
          Log.d(
              "QUYYY111",
              "Benh nhan: " + "Account: " + Constant.accountId + " Patient: " + Constant.patientId);

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

      } catch (MalformedURLException e) {
        e.printStackTrace();
        return null;
      } catch (IOException e) {
        e.printStackTrace();
        return null;
      }
      return status;
    }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // KhuongMH
    Constant.TIMES.add("07:00");
    Constant.TIMES.add("09:00");
    Constant.TIMES.add("12:00");
    Constant.TIMES.add("15:00");
    Constant.TIMES.add("18:00");
    Constant.TIMES.add("21:00");
    Constant.DATA_FROM_SERVER = HSTSUtils.loadData(getAssets());
    // KhuongMH
    am = getAssets();
    sharedPreferences =
        getApplicationContext().getSharedPreferences(Constant.PREF_NAME, Context.MODE_PRIVATE);
    Log.d("KhuongMHH -----11111  ", sharedPreferences.getString(Constant.PREF_DATA, ""));
    if (!sharedPreferences.getString(Constant.PREF_ACCOUNTID_HADLOGIN, "").equals("")) {
      Constant.accountId = sharedPreferences.getString(Constant.PREF_ACCOUNTID_HADLOGIN, "");
      Constant.PATIENT_NAME = sharedPreferences.getString(Constant.PREF_PATIENT_NAME, "");
      Constant.patientId = sharedPreferences.getString(Constant.PREF_PATIENTID_HADLOGIN, "");
      Constant.DATA_FROM_SERVER = sharedPreferences.getString(Constant.PREF_DATA, "");
      if (!sharedPreferences.getString(Constant.PREF_HADSELECTDEVICE, "").equals("")) {
        Intent myIntent = new Intent(LoginActivity.this, HomeActivity.class);
        LoginActivity.this.startActivity(myIntent);
      } else {
        //                Intent myIntent = new Intent(LoginActivity.this,
        // DeviceScanActivity.class);
        //                LoginActivity.this.startActivity(myIntent);
      }
    } else {
      ActionBar actionBar = getSupportActionBar();
      actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#3ea000")));
      actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#4ABC02")));

      setContentView(R.layout.activity_main);
      final EditText txtUsername = (EditText) findViewById(R.id.txt_login_username);
      final EditText txtPassword = (EditText) findViewById(R.id.txt_login_password);
      Button btnLogin = (Button) findViewById(R.id.btn_login_login);
      btnLogin.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {

              if (txtUsername.getText().toString().equals("258456")
                  && txtPassword.getText().toString().equals("258456")) {
                //                        Intent continueIntent = new Intent(LoginActivity.this,
                // DeviceScanActivity.class);
                Intent continueIntent = new Intent(LoginActivity.this, HomeActivity.class);
                startActivity(continueIntent);
                finish();
              } else if (txtUsername.getText().length() > 0 && txtPassword.getText().length() > 0) {

                LoginAsyncTask login = new LoginAsyncTask();
                login.execute(txtUsername.getText().toString(), txtPassword.getText().toString());

              } else {
                Toast.makeText(
                        LoginActivity.this, "Vui lòng nhập đầy đủ thông tin.", Toast.LENGTH_SHORT)
                    .show();
              }

              //                Comment o day
              //                Intent intent = new Intent(LoginActivity.this,
              // DeviceScanActivity.class);
              //                Intent intent = new Intent(LoginActivity.this, HomeActivity.class);
              ////                Intent intent = new Intent(LoginActivity.this,
              // HomeActivity2.class);
              //                startActivity(intent);
            }
          });

      //            DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
      //            Date date = new Date();
      //            String dateString = df.format(date).replaceAll("/", "");
      //            String FILENAME = "hakimquy" + ".txt";
      //
      //            File root = Environment.getExternalStorageDirectory();
      //            File dir = new File(root.getAbsolutePath() + "/kimquy");
      //            dir.mkdirs();
      //            File file = new File(dir, FILENAME);
      //            try {
      //                FileOutputStream fos = new FileOutputStream(file);
      //                PrintWriter pw = new PrintWriter(fos);
      //                pw.println("----------------------");
      //                pw.flush();
      //                pw.close();
      //                fos.close();
      //            } catch (FileNotFoundException e) {0
      //                e.printStackTrace();
      //            } catch (IOException e) {
      //                e.printStackTrace();
      //            }

    }
  }