0

I launched App1 from App2, and here are the methods in App2:

Intent resolveIntent = getPackageManager()
    .getLaunchIntentForPackage("com.example.weijunhao.launchmode");
startActivity(resolveIntent);

Then I press the home button to go to the home screen and I open App2 by pressing the launch icon.

Why does the onCreate method get called and not the onRestart method?

Daniel
  • 2,355
  • 9
  • 23
  • 30
junhao
  • 1

1 Answers1

1

When an Activity is no longer visible (like when you press the home button) it goes to the stopped state. From that state it may need to go through the onCreate() method if the system has killed the process to release memory for apps in the foreground (or system processes, I suppose).

There's a nice life-cycle diagram in Android documentation.

enter image description here

Markus Kauppinen
  • 3,025
  • 4
  • 20
  • 30