Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在一项活动中找到了全局尝试捕获的解决方案。(在这里)我可以对服务做类似的事情吗?
Thread.setDefaultUncaughtExceptionHandler()适用于您的整个应用程序。如果您愿意,您可以Thread.setDefaultUncaughtExceptionHandler()从 a调用Service,而不是从Activity. 但是,在大多数情况下,您只需为您的应用程序调用一次。
Thread.setDefaultUncaughtExceptionHandler()
Service
Activity