简体   繁体   中英

Restoring original activity as it is (like home button) when back button pressed

I am designing android application using tabHost.

TabActivity is always being launched from anther activity( suppose, Activity A). After that Activity A has no use.

When I am on tabActivity & if back button is pressed, then all goes in background( like every app). Now using task manager when I start app again, I want to retain tabActivity as it was. (like home button.) But currently I am getting Activity A. (as with back Button activities are getting destroyed.)

In short, I want to override backButton similar to Home Button.

I tried without luck with moveTaskToBack(true).

Can anybody suggest solution?

Also you could try this which should make the back button into a home button.

@Override public void onBackPressed() { this.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HOME)); }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM