0

I'm currently using a Samsung Galaxy S4.

I'm developing an app and as long as I don't exit it, it works great. However, if I leave it, it sometimes restarts itself completely and brings up the Login Activity.

I could select it from the active apps list, and it won't happen. If I go and open it up through pressing its app icon, it will sometimes restart. It will definitely restart if I remove it from the active apps list. How do I have it always return to its previous state in the app? Facebook manages it even when the app is removed from the active apps list.

Is Android garbage collecting my app for memory optimization? How would I avoid this.

David
  • 7,028
  • 10
  • 48
  • 95
  • " _However, if I leave it, it sometimes restarts itself completely and brings up the Login Activity._ " what do you mean elaborate – Elltz Nov 16 '14 at 21:42

2 Answers2

1

The onPause() and onResume() methods might be what you're looking for. Check the Facebook SDK for details on persistent authentication, even when the app is closed. Check this SO post out for more details How to keep android applications always be logged in state?

And no, I don't believe this is Android doing any garbage collection.

Community
  • 1
  • 1
AndrewSmiley
  • 1,933
  • 20
  • 32
0

Add this to the activity tag of your manifest to tell Android that your app will handle any configuration changes itself: android:configChanges="orientation|keyboardHidden"

To prevent users logging in each visit you can use shared preferences to save login credentials

Rebi
  • 1