Search code examples
androidminimize

Blank activity or fragment on reopening app after closing by pressing back button


My app get minimized when I press the back button on the home fragment, which is fine, but when I open it back up it shows me a blank activity. I guess it's not loading the fragment that it's supposed to load.

I added a text view with some text on the activity but it's not showing me that so I'm seeing something else.

How should I manage this issue?


Solution

  • Your activity has a lifecycle. If a lifecycle state is changing, then a method will be called. If you open your app, after you minimize your application, then the method "onResume()" will be called. Try to use this method in your activity to check, whether your activity is the right activity.

    UPDATE(Thanks to Santiago Gil):

    It's necessary to call finish() on the onboarding activity.