I have 2 activities and 4 fragments. I just want the code to close only when the user is on the MainActivity or welcome_fragment (I have named it that way)
I wrote some pseudocode below to help you understand my question:
Note: This code should be written under onBackPressed method in MainActivity
if(currentactivity/currentfragment)==MainActivity/welcome_fragment)
{
super.onBackPressed();
}
How do I get the current fragment or activity's id to compare it with "R.id.welcome_fragment" (or something else) and then and only then close the app onbackpressed?