Search code examples
android-activityactivity-lifecycle

Relation between System.exit(0) and onDestroy()


In my android application If i call system.exit(0) to safely terminate my application, so in this case will my onDestroy() execute before the app gets terminated?


Solution

  • No, if we call System.exit(0) it will terminate the application but it will never execute onDestroy() method.

    The System.ext(int) will shutdown the JVM. The exit code 0 indicates a normal shutdown.