简体   繁体   中英

onCreate is called again when back press

I have two activities : ActivityA and ActivityB. I start intent from ActivityA to ActivityB. When i back preess in ActivityB. My app back to ActivityA and ActivityA still in state before I start intent. But i want onCreate() in ActivityA is called again. Any help I appreciate it. Thanks

From what you have describe in comments.

" I have a ActivityA contain list from Api, in ActivityB i call request add object to server. If success the list is update in onCreate()."

  • If you destroy and recreate your previous activity then it will be some more processing time and user will have more delays to see the updates in ui. So, your activity should be as it is, you just need to catch the result from your second activity if the data was "updated", then you can just refresh the list view.

  • If you are not using viewmodel things. Better to start your second activity with startActivityForResult and then catch the result back in onActivityResult and do the list update accordingly.

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