Intent Flag doesn't work for physical button in android

65 views Asked by At

I want to create a simple app which having two activities... And I want to jump one activity from another without performing OnDestroy(); I want there to happen OnPause();

I can achieve it by using a flah like below.

Intent intent = new Intent(secondActivity.this, firstSecond.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);

But the flag only works on the BackButton Which is inside the current activity. If I click back button in my mobile the flag doesn't work..... what should I do???? any help??

Thanks in advance

1

There are 1 answers

0
David Wasser On BEST ANSWER

Override onBackPressed() and execute the same code instead:

Intent intent = new Intent(secondActivity.this, firstSecond.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);