0

I am having an issue that's closely related to support FragmentPagerAdapter holds reference to old fragments and ViewPager and fragments — what's the right way to store fragment's state?

Anyway, my problem is that my application crashes on this one activity when it gets recreated after the system kills it. As it's a pretty heavy activity and I'm debugging to implement fixes, I need to trigger the "Activity killed by android system".

Right now, I am doing "Open 20 other apps, and then hope that my app gets killed before reopening it".

Is there any better way?

PS: I have tried killing it manually (force killing) from app information. It doesn't work, as my application gets recreated from my home screen

Community
  • 1
  • 1
Stephane Maarek
  • 5,202
  • 9
  • 46
  • 87

2 Answers2

1

Actually I found an answer...

In developers settings, all the way down, look for

App -> Do not keep activities

Tick it, then launch your activity, leave it using homescreen, launch any other app (gallery or whatever), and then when you relaunch your app, it will have been killed by the android system

Stephane Maarek
  • 5,202
  • 9
  • 46
  • 87
0

Calling the finish() method should work.

If you are inside of the context of the activity then simply call finish();

If you are outside of the context. Then pass the context of the activity and call

activity.finish();
Mohammad Arman
  • 7,020
  • 2
  • 36
  • 50