Это логоут
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.action_log_out) {
val pref = getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE)
pref.edit().remove(PASSWORD).apply()
pref.edit().remove(REGION_ID).apply()
pref.edit().remove(ACCOUNTANT_ID).apply()
pref.edit().remove(PHONE_NUM).apply()
val intent = Intent(this, LoginActivity::
class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP and
Intent.FLAG_ACTIVITY_CLEAR_TASK and
Intent.FLAG_ACTIVITY_NEW_TASK
val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
drawerLayout.closeDrawers()
startActivity(intent)
finish()
}
return super.onOptionsItemSelected(item)
}
это логин
val intent = Intent(this, MainActivity::
class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or
Intent.FLAG_ACTIVITY_CLEAR_TASK or
Intent.FLAG_ACTIVITY_NEW_TASK
editor.putString(PASSWORD, et_password.text.toString())
editor.putString(NAME,
accountant.data[0].name)
editor.putString(ACCOUNTANT_ID,
accountant.data[0].accountmantId)
editor.putString(PHONE_NUM,
accountant.data[0].phoneNumber)
editor.apply()
showLoader(false)
startActivity(intent)
finish()