开发者

I am facing unexpected issue in android app

开发者 https://www.devze.com 2023-03-13 17:03 出处:网络
I have two activities: Login and List. When i log-in i display t开发者_StackOverflowhe list. When user is in the list activity and press the home button. After that clicks on the app icon it brings to

I have two activities: Login and List. When i log-in i display t开发者_StackOverflowhe list. When user is in the list activity and press the home button. After that clicks on the app icon it brings to login page for some times only. While it should display the list.

How to resolve this?


Your app is pushed out of memory sometimes in order to free memory for other apps. When it happens, app is re-launched when user enters it and first Activity is opened. The only(or not the only) way for you to maintain your app state is to store it somewhere. You could save whether user logged in or not in SharedPreferences and when Login Activity is created you could check this.


Sometimes your app will be killed depending on how much memory other applications need. Your application must save and restore its state in order to behave as if it hadn't been killed.

If you read the section on the Activity Lifecycle in the developer docs, you should understand what you need to do.

0

精彩评论

暂无评论...
验证码 换一张
取 消