the android eco system has a rule that each app will die in certain cases, while one of them is running in the background while another app run on the foreground.
however, you could have a much lower chance of being killed if the app would continue its work using a foreground service.
here's some more information about processes on android.
the downside of using a foreground service is that the user would not understand why your app needs it, since what he did is to close the app, and now he sees a notification of the app, so you should think of a good excuse why it needs to keep running .
you can also avoid directly closing the app upon pressing on the back button, by calling moveTaskToBack when onBackPressed is called. it doesn't force not killing your app, but might take a little longer to kill it.
i think the best thing is to handle restoration of your app, by saving data after login has finished, but it depends on your needs.