Android process produces logcat “has died” message very often.

前端 未结 2 1116
执笔经年
执笔经年 2020-12-15 22:25

I am working on an app that runs as a service and waits for a message. After I check the log, I find out that Android kills and restarts many processes very often! This no

2条回答
  •  情深已故
    2020-12-15 23:03

    One more possible reason can be due to customization of Thread.UncaughtExceptionHandler for the main thread.

    By default, Android OS will show an error dialog if the process is killed because of some uncaught Exception. But you can set custom Thread.UncaughtExceptionHandler and don't propagate Exception to the default Thread.UncaughtExceptionHandler, instead you can just kill the process. Then you won't see any error messages in logs except

    02-04 15:02:38.791 320 332 I ActivityManager: Process com.your.app (pid 32763) has died.

    and your process will die silently.

    That's convenient way if you want just store Exception and don't show error dialog that might be the case for some background processes.

提交回复
热议问题