Home » Android » How does android:noHistory="true" work?

How does android:noHistory="true" work?

Posted by: admin April 23, 2020 Leave a comment


Lets say I have a base activity with a menu, when I click on menu item A, it goes to activity A. I open the menu again, and go to B. From B I go back to A, and back and fourth like this for a while.

So the stack would be A, B, A, B, A, B, ….
And when I hit the back button, it goes backwards through the stack as expected.

However lets say I don’t want this functionality, so I add to my manifest, android:noHistory="true". So when I hit the back button it exits the application instead of going though the stack.

Now the illusion makes it seem, lets say if I’m in activity A, I use the menu and go to activity B, the stack would just be B, because I can’t go back to A.

But, when using noHistory="true", does the true stack of A, B, A, B, A, B exist? Rather, is every call to an activity by using the menu instantiating a new copy of that activity, but the user can’t see it? Would this be causing resource issues?

Or when noHistory="false", does the back button just call something like startAcitvity(intent) again or is it going through each new copy that was instantiated?

I’m concerned with resource issues and not slowing down a users android device.

How to&Answers:

From the docs about noHistory:

A value of “true” means that the activity will not leave a historical trace. It will not remain in the activity stack for the task, so the user will not be able to return to it.

Regarding your question:

does the true stack of A, B, A, B, A, B exist?

The docs would indicate no.

I’m concerned with resource issues and not slowing down a users android device.

You really don’t need to worry about this. The OS should handle the cleanup of activities when memory is getting low. Its more likely that poor use of bitmaps or logic in your activities will result in performance slowdowns.


android:noHistory=“true” works :-

Let suppose you have opened “your app”.

You are on homepage Activity now,

After it you go to the another(second) activity.Here from second activity you press the home button of mobile device or open the some other application.

Now again if you open “your app” it will go to the homepage of app instead of going to the activity which one you left the app(i.e.second activity).


I had few fragments in my app and it seemed difficult to get out to the home screen by pressing back button without entering Launcher Activity of my app. I used android:noHistory=”true” in the manifest of the launcher Activity of my app and the problem gets solved now.