search

Home  >  Q&A  >  body text

Android 调用system.exit(0)后APP自动重启。

返回键调用 system.exit(0) 此方法以后 APP会自动重启。有谁有高见?指导一下。

伊谢尔伦伊谢尔伦2772 days ago813

reply all(4)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 17:35:45

    There are several situations:

    1. Set up a custom exception handler, then system.exit(0) throws an exception that is caught by the handler, and then the code in the handler reloads the application.

    2. There is a service in the program, and the return value of the service's onStartCommand method is set to START_STICKY. The semantics of this return value is that when the service is killed, restart it. system.exit(0) will kill all threads, including services, and then the system will restart the service according to the START_STICKY setting.

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 17:35:45

    Maybe it crashed before exiting, check the log carefully

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 17:35:45

    Your method is not suitable for android

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 17:35:45

    It is recommended to use finish()

    reply
    0
  • Cancelreply