So in my app I have a button to open gmail so the user can check for a verification code.
I use this code to open gmail:
val intent = Intent(Intent.ACTION_MAIN)
intent.addCategory(Intent.CATEGORY_APP_EMAIL)
try {
activity?.startActivity(intent)
} catch (e: Exception) {
activity?.let {
AlertDialog.Builder(it)
.setTitle("Email App Not Found")
.show()
}
}
It is working great to launch gmail, however what I need is for the back button to come back to my app.
Currently when I hit the back button from gmail it will minimize my app, and then reopening my app just reopens gmail with no way to get back to my app without fully closing and reopening it.
Is there a way to override the back button to get back to my app from gmail?