Closed arnabeshd closed 2 years ago
Overriding onBackPressed() as menu item.
override fun onOptionsItemSelected(item: MenuItem): Boolean { val frequency = viewModel.TGFrequency.toString() val level = viewModel.TGLevel.toString() when (item.itemId){ android.R.id.home -> onBackPressed() /*onBackPressed() override*/ R.id.misave -> viewModel.saveToDataStore(frequency,level) R.id.givefeedback -> Toast.makeText(this,"Thanks for your feedback",Toast.LENGTH_SHORT).show() R.id.closeapp -> finish() } return true }
Overriding onBackPressed() as menu item.