开发者

Android: Lifecycle problem - leaving the application

开发者 https://www.devze.com 2023-01-08 09:30 出处:网络
The first activity in my app is a splash screen with a Progress Dialog in which I load data from a Web Service.

The first activity in my app is a splash screen with a Progress Dialog in which I load data from a Web Service.

When this is done I start the next activity and call finish() in the first activity's onPause(), in order for it to not appear again.

The next activity is my开发者_运维技巧 main menu and on from there I browse the application.

The problem is when I want to leave the application. I return to the main menu from whichever activity I have been to and press BACK or HOME.

If shortly after I launch the app again, my main menu immediately appears and I do not go through the splash screen where the data is brought over. Also, it seems that the data held prior to leaving was released. As a result, the activities I launch from the main menu (which depend on the data fetched during the splash screen) turn up empty.

Does anyone have an idea how to go about this?

Thanks, Rob


Do you store your data in the bundle that get's loaded by onCreate() when leaving your main activity?

I would recommend to read the section about Saving activity state on http://developer.android.com/guide/topics/fundamentals.html


As far as i know, The Android Mobile has the Home and key Button to achieve the MultiTasking/Run the App in Background. When you Click Back, It finish the current Activity as Default. When you Click Home, It directly navigate to the Home screen and your App will run at background.

So your scenario is not possible yet and also its not a effective multitasking Environment. So you want to close your app. you have to navigate to the activities with BACK button upto home Screen. If you press HOME, Its Starts the Activity when you leaved.

0

精彩评论

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