Android: launchmode = "standard": In this startup mode, every startactivity () is used to create a new instance in the memory.
Android: launchmode = "singletop": if a reference to this activity exists at the top of the stack, startactivity () will not create a new oncreate, but reuse existing instances, call the onnewintent () method.
Android: launchmode = "singletask": as long as there is a reference to this activity in the entire stack, startactivity () will not create a new oncreate, but reuse the existing instance and call onnewintent () method.
Android: launchmode = "singleinstance": After being created for the first time, another task stack is enabled, and only one reference of the new stack can exist. startactivity () instead of creating a new instance in oncreate, the existing instance is reused and the onnewintent () method is called.
Let's take a look at the startactivityforresult () method: (test)
Now we can demonstrate that a startactivityforresult () enables B and B returns data;
If a is standardb with singletask and singleinstance, an error is returned. A calls startactivityforresult () to enable B, and CALLS onactivityresult () of a immediately (); in this case, no data is returned for Operation B (not obtained yet). If operation B is singletop and standard, data is returned normally. If a is singletop, same as above. If a is singletask, same as above. If a is singleinstance, all data is returned.
To sum up, if you need to enable the System camera in your activity and then return data, please do not set your activity to singleinstance; if it is not a singleinstance, therefore, the onactivityresult method cannot be used to obtain the returned data. You can obtain the image from the SD card after saving the photo.
The setresult () method is invalid in onpause and ondestory. Other lifecycle methods are valid.
Ondestory () is called every time you press the back key ();
Calling this. Finish () will automatically call ondestory ();