I have an application on android in which there are such activites: login screen (LoginActivity), main screen (MainScreen). The logic is that the user enters a password and username when logging in and if everything is ok, if the server has sent its approval, then we go to the main screen. On the login screen there is a toolbar on which the button for selecting the application language is hanging. The whole principle of changing the language I described in my previous question: A complete change of language in the android application . That is, when I click on a list item, my LoginActivity re- LoginActivity is automatically done and the language is saved, for subsequent activations and for the set after the application is restarted.
And now what exactly is my problem: if you fill in the fields with login and username and then do not click on the button to send a request to the server. Instead of sending a request to the server, we decide that we first need to change the language in the application, and accordingly click on the button on the toolbar -> then select the language from the list and click on it. In this case, the fields hang filled but the "Login" button was not pressed. And then some kind of magic happens)) After choosing a language, I have made recreate activations, but for some reason I switch to the main screen, although I have a clear condition that I switch to the main screen only under two conditions - if the user already previously used the application, or the user pressed a button and a satisfactory answer came from the server.
Here are two mentions of the main screen to which the transition is made: 1)
if (response.isSuccessful()) { Intent intent = new Intent(LoginActivity.this, MainScreen.class); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); finish(); overridePendingTransition(0, 0); 2)
sp = getSharedPreferences(REFRESH_TOKEN, MODE_PRIVATE); final boolean hasVisited = sp.getBoolean("hasVisited", false); user.setChecked(hasVisited); if (hasVisited) { Intent intent = new Intent(LoginActivity.this, MainScreen.class); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); finish(); overridePendingTransition(0, 0); I can not understand what could be the problem, I really hope for your help.
hasVisitedrecorded inhasVisited? - Enikeyschik Septemberfalseis set if the user has clicked logout - Andrew Goroshkouser.setChecked(hasVisited);? - Enikeyschik SeptemberhasVisitedreadstrue. See the value of the variable after reading in progress. - Enikeyschik September