2

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!

Eloi Navarro
  • 1,355
  • 1
  • 13
  • 26

2 Answers2

0

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

Zeeshan
  • 601
  • 1
  • 7
  • 19
0

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.

Eloi Navarro
  • 1,355
  • 1
  • 13
  • 26
  • 1
    hehe I guess there is no way to give me any points, but I'm still glad to help :) btw accept ur own answer, so others will see how to solve similar issue, cheers:) – Stigi Jan 04 '13 at 00:29