Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have some problems with the default Android lifecyle.

My app has an Activity (let's call it A) and a MapActivity (let's call it M)

Activity A has an AsyncTask to retrieve an image from an URL (EDIT3: which seems to not affect my issue, but I mention it in order to give full info) and the MapActivity M is currently an empty map, no config or modifications made.

My use case is the folowing:

I go through my app normally, and end up starting A with no errors. When I start M from A everything works as expected, but when I go back, Activity A is already finished.

I Log.d every step in the lifecycle in both activities and found the following:

Start Activity A

onCreate  - A
onStart   - A
onResume  - A

Start Activity M

onPause   - A
onCreate  - M
onStart   - M
onResume  - M
onStop    - A

Back on Activity M

onPause   - M
onDestroy - A
onStop    - M
onDestroy - M

So I end up finishing Activity A and M when I press the back button on M

I tried different kind of Activities (MapActivities, Activities, from the same package, from different packages) with the same exact result.

EDIT:

  • I don't use finish(); method anywhere
  • My activity is started with the folowing code:

Intent I = new Intent(context, ActivityName.class); context.startActivity(I);

EDIT2:

  • Checked isFinishing method on the Activity A onPause step, and the result is false so it was not suposed to be finishing

Any idea? is there something I am missing? Thx in advance for your time and ideas!

share|improve this question

2 Answers 2

While going from Activity M to Activity A, make sure you don't use finish(); since it removes the current activity from the stack.

share|improve this answer
up vote 0 down vote accepted

Thanks to @Stigi who pointed me in the right path to keep debugging. (Can I give you points somehow?)

In my case android:noHistory="true" was set on the Manifest.xml so when I came back from Activity M to Ait was not on the pile, and it looked like it was closed.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["                  <li><a href=\"//area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"//careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2015 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a>                   with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2015.1.30.2262\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Stack Overflow works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt=\"\" class=\"dno\"></div>\r\n    </nos"], "copyright__copyright__copyright": ["ote accepted\n\nThanks to @Stigi who pointed me in the right path to keep debugging. (Can I give you points somehow?)\n\nIn my case android:noHistory=\"true\" was set on the Manifest.xml so when I came back from Activity M to Ait was not on the pile, and it looked like it was closed.\n\nshare|improve this answer\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}