简体   繁体   中英

Android recreating activity after user kills the app

I have a singleTop activity (ActivityB) which is called with a data object ( Bundle mData = getIntent().getExtras() ) put by previous activity (ActivityA). ActivityB does some work in the background and shows to the user a progress bar. After it is finished I am calling next activity (ActivityC) wich needs data object (mData) from the ActivityB.

Problem : while ActivityB does some work, user closes the app by swiping it from the task manager. After user starts the app again. ActivityB is shown everything is ok, but mData is lost, which is a problem for ActivityC.

Any ideas how to handle this scenario? Persist data in SQLite or shared preferences is not an option for me.

Thanks in advance!

Not a lot to go on here, but ......

Swiping with task manager is a hard kill. No callback, no notification.

If possible keep track of your processing state in activity B and save off the data either to a database or a file periodically.

When you restart check the processing state and restore the data from the file or database.

Alternatively, just detect that you did not finish your processing and start Activity B over at the beginning.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM