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.
activity is the subelement of application and represents an activity that must be defined in the AndroidManifest. xml file. It has many attributes such as label, name, theme, launchMode etc. android:label represents a label i.e. displayed on the screen.
The android:label is to define your app name, which is display in the installed application list. If you want to change the app name in home screen, check android:label inside the <activity /> tag.
The easiest way is to give the LoginActivity a “android:noHistory = true” attribute in the manifest file. That instructs Android to remove the given activity from the history stack thereby avoiding the aforementioned behavior altogether.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With