androidactivity-stack

android parent activity killed on startActivity


I have a simple application with a listview. When a user taps on a list item, i start a new activity

Intent eventdetails = new Intent(HomeActivity.this,EventDetailsActivity.class);
eventdetails.putExtra("eventId", ev.getId());
eventdetails.putExtra("eventDate", ev.getEnglishDate());
startActivity(eventdetails);

As soon as the EventDetailsActivity is started, the HomeActivity is destroyed (onDestroy is called). WHen the user hits the back button from EventDetailsActivity, the HomeActivity is recreated which is something i do not want.

I havent been able to figure out why the HomeActivity is killed in the first place. I checked the activity stack using udb as well and it does not show the HomeActivity

Running activities (most recent first):
Run #0: ActivityRecord{43938cc8 com.app.event/.EventDetailsActivity}

This is happening only on Samsung Galaxy Note 2

Any idea why this would be happening ?


Solution

  • this will happen when the user has enabled this setting

    goto settings->Developer options

    in that in APPS category(scroll down to see), see the option
    Don't keep Activities (Destroy every Activity as soon as user leaves it).

    see this option is selected or not