I have already created users, a name and password in my database. Then the user name is passed to the next activity. And with the next activity from the menu, you can click the logout button and it should display the registration window. But nothing works for me, the "exit" button does not flip to another screen, but just goes into the same one...
mSettings = getSharedPreferences("my_storage", Context.MODE_PRIVATE);
editor = mSettings.edit();
if(mSettings.getBoolean("is_logged", true)){
startActivity(new Intent(Authorisation.this, Menu.class));
finish();
}
editor.putBoolean("is_logged", false).apply();
and after that, I pass the name and password to the editor, set the value to true. Where did I go wrong?
Boolean checkuserpass = DB.checkusernamepassword(user, pass);
if(checkuserpass == true){
Intent intent = new Intent(getApplicationContext(), Menu.class);
intent.putExtra("name", user);
NAME = user;
editor.putString(NAME, user).apply();
editor.putString("PASSWORD", pass).apply();
editor.putBoolean("is_logged", true).apply();
startActivity(intent);
The code of another menu activity. Here I am trying to pass the values to the header (username - name during registration).
@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
int id = item.getItemId();
Intent intent = new Intent(Menu.this, Authorisation.class);
Authorisation authorisation = new Authorisation();
authorisation.log_out();
startActivity(intent);
finish();
return true;
}