When an Android application is taken to the background, it can retain its state of the instance if it is killed due to low memory (see Activity: onSaveInstanceState () and the bundle argument for Activity: onCreate (Bundle savedInstanceState) ).
The default behavior is to preserve the state of the view hierarchy, so for many cases you do not need to write any code, and it "just works" [tm].
Now for response-native this is not true. Responsive native applications are hosted in one MainActivity, and their state is contained in the javascript interpreter in the application.
I created a sample repository with short documentation on how to reproduce my problem here: https://github.com/einvalentin/react-native-state-test
I would like action-native to connect to the serialization mechanism of the native android application, allowing application developers to intercept if they need custom serialization. Alternatively, I could see how I extend MainActivity to forward lifecycle events to the Javascript level and do some custom state serialization manually, but this is a bit inconvenient.
Is there an obvious way that I forgot to save state in a native-reaction so that applications that were killed in the background do not restart from scratch? This can happen, for example, on low memory devices that receive a phone call while interacting with your application.
Thanks a lot!
source share