I need to know if there is any way to know when on an Activity what is the Activity that will be opened when the back button is pressed. I suppose i can take a look at the activity stack but i need some pointer on how to do it.
Thanks in advance.
EDIT: Thank for all the answers but i still want to explain the real problem.
I have an App that has a bunch of activities that consume a lot of power (sensor, gps and wifi), that i want to keep quiet when i’m not using that ‘Task’ (i.e going to do something else).
How can i trap the event of not having nothing more of my application in the back-stack?
Send along an intent extra from
ActivityXtoActivityY. The extra could be a reference to a constant value which identifies an activity.ActivityX:startActivity(new Intent(context, ActivityY.class).putExtra("fromActivity", Const.EXTRA_FROM_ACTIVITY_X));ActivityYB:Where
Constis a class holding uniquestatic final intvariables such asEXTRA_FROM_ACTIVITY_X