android - Can parent Activity be terminated before onActivityResult is called -


is possible parent activity terminated before onactivityresult() called? if that's case, whatever local variables maintained in parent activity, may not valid (initialized) when onactivityresult() called.

i periodically null pointer exception when onactivityresult() called variables set in parent activity, if parent activity had been destroyed before return child activity, these variables no long valid.

is possible parent activity terminated before onactivityresult() called?

activities not "terminated". activities destroyed. processes terminated.

if activity being started via startactivityforresult() in separate app yours, entirely possible process terminated while app in background. see lot action_image_capture, example.

also, configuration change can destroy activity part of coming foreground. suppose start in portrait mode. start other activity. user rotates device landscape, presses back. "parent activity" destroyed , recreated.

however, otherwise, way "parent activity" should destroyed if call finish() on it.

i periodically null pointer exception when onactivityresult() called variables set in parent activity, if parent activity had been destroyed before return child activity, these variables no long valid.

you need repopulate variables, such saving values in onsaveinstancestate() bundle , restoring them in onrestoreinstancestate(). handle both process-was-terminated scenario (assuming user returns reasonably quickly) , configuration-change scenario.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -