Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android

aakarshrestha
aakarshrestha
6,509 Points

Save the app state when the app is swiped left or right from the overview screen or recent apps list.

When I swipe the app, that I am logged into, from overview screen or recent apps list the app closes completely and I have to log in to the app again. How to prevent the log in process again and save the state of the application when accessed again?

For example: Open a facebook mobile app in your android phone. Go to the overview screen or recent apps list screen, you will see all the apps you have opened and among those app you will see facebook app as well. When you swipe the facebook app either left or right, app is no longer displayed in the overview screen or recent apps list. Now open the facebook app, you are already logged in and you state is saved.

How do I achieve the same behavior in my app?

Any suggest is highly appreciated!

Happy coding!

2 Answers

aakarshrestha
aakarshrestha
6,509 Points

I was able to get what i wanted, which is a user should be able to auto login to the app if the app is removed from the recent apps list.

I used sharedpreference for it and it works like a charm.

If anyone needs help or wants to know more about it, please comment and I will be more than happy to share my experience with you.

Happy coding!

Seth Kroger
Seth Kroger
56,407 Points

That's a topic that will take more than a forum post to answer but luckily Treehouse has a course on the Android Activity Lifecycle

aakarshrestha
aakarshrestha
6,509 Points

I have gone through the Android Activity Lifecycle and it does not have what I am looking for. Thanks for the reply though.