title: Before intent is changing spinner also change its value
body: <p>After I press the button "ΕΙΣΟΔΟΣ" a new intent is called and the spinner change its value, to first item. Although it does not effect my app, it is disturbing. I cannot find where the issue is...</p>
  
  <p>the code of this activity:</p>
  
  <pre><code>    @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main_login);
  
          //region find views by their IDs
          spinnerNames = findViewById(R.id.spin);
          startButton = findViewById(R.id.btn_start_log_in);
          etNameLogIn = findViewById(R.id.et_name_log_in);
          bodyHuman = findViewById(R.id.ll_body_human);
          bodyWiFi = findViewById(R.id.ll_body_wifi);
          imageHuman = findViewById(R.id.rl_image_human);
          imageWiFi = findViewById(R.id.rl_image_wifi);
          //endregion
  
          checkConnection();
  
          //region set on item selected listener and set also editText name log in when select from spinner
          spinnerNames.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
              @Override
              public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) {
  
                  firstTime += 1;
  
                  SpinnerItem clickedItem = (SpinnerItem) parent.getItemAtPosition(position);
  
                  String clickedName = clickedItem.getName();
  
                  if (firstTime &gt; 1) {
                      etNameLogIn.setText(clickedName);
                  }
              }
  
              @Override
              public void onNothingSelected(AdapterView&lt;?&gt; parent) {
  
              }
          });
          //endregion
  
          etNameLogIn.setOnEditorActionListener(new TextView.OnEditorActionListener() {
              public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                  if(event != null &amp;&amp; event.getKeyCode() == KeyEvent.KEYCODE_ENTER &amp;&amp; event.getAction() == KeyEvent.ACTION_DOWN || actionId == EditorInfo.IME_ACTION_DONE ) {
                      InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                      imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
  
  
                      getWindow().getDecorView().clearFocus();
  
                  }
                  return false;
              }
          });
  
          startButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  if (startButton.getText().equals("ΑΝΑΝΕΩΣΗ")) {
                      checkConnection();
                  } else if (startButton.getText().equals("ΕΙΣΟΔΟΣ")) {
                      checkConnection();
  
                      // region check whether editText log in name exists in spinner if not add it to database and spinner
                      for (int z = 0; z &lt; mspinnerList.size(); z++) {
                          if (etNameLogIn.getText().toString().equals(mspinnerList.get(z).getName())) {
                              yes += 1;
                          }
                      }
  
                      if (yes == 0) {
                          mspinnerList.add(new SpinnerItem(etNameLogIn.getText().toString(), R.drawable.next_48));
                          try {
                              ConnectionHelper connectionHelper = new ConnectionHelper();
                              connect = connectionHelper.connections();
                              if (connect == null) {
                                  Toast.makeText(getApplicationContext(), "Δεν υπάρχει σύνδεση με τη βάση δεδομένων.",
                                          Toast.LENGTH_LONG).show();
  
                              } else {
                                  String sqlQuery = myQuery;
                                  Statement stmt = connect.createStatement();
                                  stmt.executeUpdate(sqlQuery);
  
                                  isSuccess = true;
                                  connect.close();
                              }
  
                          } catch (Exception ex) {
                              isSuccess = false;
                          }
                      }
                      //endregion
  
                      if (startButton.getText().equals("ΕΙΣΟΔΟΣ")) {
                          Intent myIntent = new Intent(MainLoginActivity.this, MainActivity.class);
                          myIntent.putExtra("NAME", etNameLogIn.getText().toString()); //Optional parameters
                          MainLoginActivity.this.startActivity(myIntent);
                      }
  
                  }
  
              }
          });
      }
  
      @Override
      public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
          if(grantResults[0] == PackageManager.PERMISSION_GRANTED &amp;&amp; requestCode == LOCATION){
              //User allowed the location and you can read it now
              checkConnection();
          }
      }
  
      private void checkConnection() {
          //If requested permission isn't Granted yet
          if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
              //Request permission from user
              ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, LOCATION);
          }else{//Permission already granted
              WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
              WifiInfo wifiInfo = wifiManager.getConnectionInfo();
              if(wifiInfo.getSupplicantState() == SupplicantState.COMPLETED){
                  String ssid = wifiInfo.getSSID();//Here you can access your SSID
                  if (ssid.equals("\"private-Pda\"") || ssid.equals("\"AndroidWifi\"") ) {
                      initList();
                      imageHuman.setVisibility(View.VISIBLE);
                      bodyHuman.setVisibility(View.VISIBLE);
                      imageWiFi.setVisibility(View.GONE);
                      bodyWiFi.setVisibility(View.GONE);
                      startButton.setText("ΕΙΣΟΔΟΣ");
                  } else  {
                      imageWiFi.setVisibility(View.VISIBLE);
                      bodyWiFi.setVisibility(View.VISIBLE);
                      imageHuman.setVisibility(View.GONE);
                      bodyHuman.setVisibility(View.GONE);
                      startButton.setText("ΑΝΑΝΕΩΣΗ");
                  }
  
              } else  {
                  imageWiFi.setVisibility(View.VISIBLE);
                  bodyWiFi.setVisibility(View.VISIBLE);
                  imageHuman.setVisibility(View.GONE);
                  bodyHuman.setVisibility(View.GONE);
                  startButton.setText("ΑΝΑΝΕΩΣΗ");
              }
          }
      }
  
      private void initList() {
          mspinnerList = new ArrayList&lt;&gt;();
          try {
              ConnectionHelper connectionHelper = new ConnectionHelper();
              connect = connectionHelper.connections();
              if (connect == null) {
                  Toast.makeText(getApplicationContext(), "Δεν υπάρχει σύνδεση με τη βάση δεδομένων.",
                          Toast.LENGTH_LONG).show();
  
              } else {
                  String sqlQuery = "SELECT ONOMA FROM [KOMBOS].[dbo].[CCCAPOGRAFI]";
                  Statement stmt = connect.createStatement();
                  ResultSet rs = stmt.executeQuery(sqlQuery);
  
                  while (rs.next()) {
                      mspinnerList.add(new SpinnerItem(rs.getString("ONOMA"), R.drawable.next_48));
                  }
  
                  mAdapter = new SpinnerAdapter(this, mspinnerList);
                  spinnerNames.setAdapter(mAdapter);
  
  
                  isSuccess = true;
                  connect.close();
              }
  
          } catch (Exception ex) {
              isSuccess = false;
          }
      }
  }
  </code></pre>
  
  <p><a href="https://youtu.be/kQP2buqHnvQ" rel="nofollow noreferrer">Video</a> that represents how my app is behaving. I have searched but couldn't find anything.</p>