This happens whether I call finish()
or use the hardware back button.
This is happening on 4.4.2 x86 AVD emulator, but not physical 5.1.1 device.
This only happens in landscape mode for some reason.
I can recreate this by following the exact steps repeatedly, but I have not been able to create a minimal example yet, trimming out all my companies private information.
I was certain I had seen some reference to this, on stack overflow in the past, but I cannot find it.
I have found one suspect activity launch in my application, that uses
getApplicationContext().startActivity(i);
with flag FLAG_ACTIVITY_NEW_TASK
The flow that creates this is
- Open Application with the table held in landscape. ( Applicaiton opens in
MainActivity
) - Login ( this is the step that used
FLAG_ACTIVITY_NEW_TASK
) - Logout ( this calls HomeActivity.startActivity with flag
FLAG_ACTIVITY_CLEAR_TOP
, and re-startsMainActivity
) - Log in again ( this is why I suspect
FLAG_ACTIVITY_NEW_TASK
, but I CANNOT recreate this in portrait ) - Launch a specific activity that goes through fragments
- Go through the 4 fragments, and on the 4th one, either press
Back
or hit the save button that callsfinish()
; - The Activity will finish, but the whole application will move to the background.
- (At this point, I can re-open the activity form the launcher and it properly resumes at the previous activity )
The only difference I can see using adb shell dumpsys activity activities
is one entry that shows when that last fragment is loaded, this value has changed:
Hist #3: ActivityRecord{b4410058 u0 <package>/<DetailActivity> t20}
packageName=<package> processName=<package>
launchedFromUid=10058 launchedFromPackage=<package> userId=0
app=ProcessRecord{b43f4040 4154:<package>/u0a58}
Intent { cmp=<package>/<DetailActivity> (has extras) }
**frontOfTask=false** task=TaskRecord{b43ced20 #20 A=<package> U=0 sz=4}
And this also changes
mFocusedStack=ActivityStack{b44a83a0 stackId=10, 1 tasks} mStackState=STACK_STATE_HOME_TO_FRONT
As I mentioned, I have tried creating a minimal example, but when I luch all the activities in the same order in a Test App ( that does not do any of my network transactions etc. ), the issue is not visible.
TL:DR; Sometimes in landscape mode, finishing an activity takes me to device home, instead of the previous activity - This is with finish()
or the device back button.
And to point out again - this ONLY happens when I combine running the activity 100% in landscape from start to finish ( no rotation ), and when I log out and log back in.
I do not see any items in the log about using too much memory.
As a test to eliminate some recommendations, I did put android:configChanges="keyboardHidden|orientation|screenSize"
back on every activity, and I do get the same behavior
I will note that all of our fragments in my application are retained, but I am not getting any errors about out of memory, but it's a thought.