How to finish any previous activity in application stack (at any level , I mean not immediate parent) , from current activity like on some particular event I want to invalid
I know this answer may be late, but I'm still going to post it in case someone is looking for something like this.
What I did is I declared a static handler in in ACTIVITY_A
public static Handler h;
and in my onCreate()
method for ACTIVITY_A
, I have
h = new Handler() {
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch(msg.what) {
case 0:
finish();
break;
}
}
};
Now, from any activity after this one, such asACTIVITY_B
, or ACTIVITY_C
I can call
ACTIVITY_A.h.sendEmptyMessage(0);
which then calls finish()
in ACTIVITY_A
and ta-da! ACTIVITY_A
is finished from a different activity.