Question

I start an Activity using startActivityWithResult:

class MyActivity extends Activity {
    void go() {
         i = new Intent(this, OtherActivity.class);
         startActivityForResult(i, OtherActivity.CODE_ADD);
    }
}

is it possible that onCreate of MyActivity is called when OtherActivity is done? Or can I be sure that only onStop, onResume and onActivityResult are called?

Was it helpful?

Solution

is it possible that onCreate of MyActivity is called when OtherActivity is done?

For an OtherActivity that is part of your own app, your MyActivity instance should be left alone, unless you finish() it yourself. Assuming you do not finish() it yourself, onCreate() should not be called on your MyActivity instance.

If you are launching another app, it is possible that your process will be terminated to free up system RAM, because your app will have moved into the background. This happens a lot when launching a camera app. If your process was terminated, returning to MyActivity would result in onCreate().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top