Here's an explanation of what I am doing in my application and what the output from adb shell dumpsys activity is. I am starting at the FriendsActivity.
Pressed the logout button, list of saved accounts now showing. Called using:
Intent i = new Intent("com.company.app.common.ACCOUNTS");
... put extras ...
startActivityForResult(i, 2);
dumpsys activity output:
Running activities (most recent first):
TaskRecord{44003ac8 #45 A com.company.app.friends}
Run #6: HistoryRecord{43ffafd8 com.company.app/.common.AccountsActivity}
Run #5: HistoryRecord{43ea8810 com.company.app/.friends.FriendsActivity}
TaskRecord{4409b238 #44 A com.android.settings}
Run #4: HistoryRecord{43f1f8b0 com.android.packageinstaller/.UninstallAppProgress}
Run #3: HistoryRecord{43ed3390 com.android.settings/.ManageApplications}
Run #2: HistoryRecord{43e17738 com.android.settings/.ApplicationSettings}
Run #1: HistoryRecord{4409a160 com.android.settings/.Settings}
TaskRecord{43f679e0 #2 A com.android.launcher}
Run #0: HistoryRecord{43f63640 com.android.launcher/com.android.launcher2.Launcher}
Chose an account to log into, the login activity shoes up with fields filled out.
Intent i = new Intent();
i.setClass(AccountsActivity.this, LoginActivity.class);
... put extras ...
startActivityForResult(i, 1);
dumpsys activity output:
Running activities (most recent first):
TaskRecord{44003ac8 #45 A com.company.app.friends}
Run #7: HistoryRecord{4402b078 com.company.app/.common.LoginActivity}
Run #6: HistoryRecord{43ffafd8 com.company.app/.common.AccountsActivity}
Run #5: HistoryRecord{43ea8810 com.company.app/.friends.FriendsActivity}
TaskRecord{4409b238 #44 A com.android.settings}
Run #4: HistoryRecord{43f1f8b0 com.android.packageinstaller/.UninstallAppProgress}
Run #3: HistoryRecord{43ed3390 com.android.settings/.ManageApplications}
Run #2: HistoryRecord{43e17738 com.android.settings/.ApplicationSettings}
Run #1: HistoryRecord{4409a160 com.android.settings/.Settings}
TaskRecord{43f679e0 #2 A com.android.launcher}
Run #0: HistoryRecord{43f63640 com.android.launcher/com.android.launcher2.Launcher}
Pressed the login button which runs:
Intent i = new Intent();
... put extras ...
setResult(RESULT_OK, i);
finish();
Returns to AccountsActivity onActivityResult:
if (requestCode == 1) {
if (resultCode == 2) {
...
} else {
setResult(resultCode);
finish();
}
}
ACCOUNTSACTIVITY REMAINS RUNNING!
Running activities (most recent first):
TaskRecord{44003ac8 #45 A com.company.app.friends}
Run #6: HistoryRecord{43fdeee8 com.company.app/.common.AccountsActivity}
Run #5: HistoryRecord{43ea8810 com.company.app/.friends.FriendsActivity}
TaskRecord{4409b238 #44 A com.android.settings}
Run #4: HistoryRecord{43f1f8b0 com.android.packageinstaller/.UninstallAppProgress}
Run #3: HistoryRecord{43ed3390 com.android.settings/.ManageApplications}
Run #2: HistoryRecord{43e17738 com.android.settings/.ApplicationSettings}
Run #1: HistoryRecord{4409a160 com.android.settings/.Settings}
TaskRecord{43f679e0 #2 A com.android.launcher}
Run #0: HistoryRecord{43f63640 com.android.launcher/com.android.launcher2.Launcher}
Choose an account again, back at login screen.
Running activities (most recent first):
TaskRecord{44003ac8 #45 A com.company.app.friends}
Run #7: HistoryRecord{43ec7840 com.company.app/.common.LoginActivity}
Run #6: HistoryRecord{43fdeee8 com.company.app/.common.AccountsActivity}
Run #5: HistoryRecord{43ea8810 com.company.app/.friends.FriendsActivity}
TaskRecord{4409b238 #44 A com.android.settings}
Run #4: HistoryRecord{43f1f8b0 com.android.packageinstaller/.UninstallAppProgress}
Run #3: HistoryRecord{43ed3390 com.android.settings/.ManageApplications}
Run #2: HistoryRecord{43e17738 com.android.settings/.ApplicationSettings}
Run #1: HistoryRecord{4409a160 com.android.settings/.Settings}
TaskRecord{43f679e0 #2 A com.android.launcher}
Run #0: HistoryRecord{43f63640 com.android.launcher/com.android.launcher2.Launcher}
Press login button, returns to the Friends list as it should, but the activity stack is strange.
Running activities (most recent first):
TaskRecord{44003ac8 #45 A com.company.app.friends}
Run #7: HistoryRecord{43ea8810 com.company.app/.friends.FriendsActivity}
Run #6: HistoryRecord{43fdeee8 com.company.app/.common.AccountsActivity}
Run #5: HistoryRecord{43ec7840 com.company.app/.common.LoginActivity}
TaskRecord{4409b238 #44 A com.android.settings}
Run #4: HistoryRecord{43f1f8b0 com.android.packageinstaller/.UninstallAppProgress}
Run #3: HistoryRecord{43ed3390 com.android.settings/.ManageApplications}
Run #2: HistoryRecord{43e17738 com.android.settings/.ApplicationSettings}
Run #1: HistoryRecord{4409a160 com.android.settings/.Settings}
TaskRecord{43f679e0 #2 A com.android.launcher}
Run #0: HistoryRecord{43f63640 com.android.launcher/com.android.launcher2.Launcher}
Press the back button, and the application closes. Hit the logout button again and the cycle repeats.
I have no idea what is going on and why this is happening. I did notice this in the last dump though:
Activities waiting for another to become visible:
TaskRecord{44003ac8 #45 A com.company.app.friends}
Wait #1: HistoryRecord{43fdeee8 com.company.app/.common.AccountsActivity}
Wait #0: HistoryRecord{43ec7840 com.company.app/.common.LoginActivity}
Activities waiting to finish:
TaskRecord{44003ac8 #45 A com.company.app.friends}
Fin #1: HistoryRecord{43fdeee8 com.company.app/.common.AccountsActivity}
Fin #0: HistoryRecord{43ec7840 com.company.app/.common.LoginActivity}
Very likely has something to do with this problem, but what does it mean?