android - android中严格模式线程策略的确切用途是什么?

标签 android error-handling

严格模式线程策略类是否有助于管理/处理错误?

如果是,是什么类型的错误?

最佳答案

StrictMode is a developer tool which detects things you might be doing by accident and brings them to your attention so you can fix them.

警告:不要将严格模式用作在主线程上执行网络操作的 hack,因为它会阻塞您的 UI 线程。这是一个非常非常糟糕的做法。严格模式是为了帮助您捕获开发人员的任何“意外编程”

StrictMode is most commonly used to catch accidental disk or network access on the application's main thread, where UI operations are received and animations take place. Keeping disk and network operations off the main thread makes for much smoother, more responsive applications. By keeping your application's main thread responsive, you also prevent ANR dialogs from being shown to users.

因此您可以使用 StrictMode 来捕获磁盘/网络访问而不会导致您的应用程序崩溃。在 GP 上启动您的应用程序时请小心将其关闭。

关于android - android中严格模式线程策略的确切用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29597127/

相关文章:

java - addOnScrollListener 不起作用(Android)

安卓工作室 StackOverFlowError : null

java - 如何获得年龄并将其用于另一项 Activity ?

asp.net-mvc-4 - 混合使用MVC和Web API错误处理

r - 自动尝试优化其他初始值

PowerShell 表单,尝试/捕获未正确停止应用程序

android - 如何在应用程序执行之间保留 webview cookie?

c# - 从其他 Activity 的构造函数开始 Activity ?

node.js - Node Express RESTful API默认引擎用于错误处理

vb.net - Visual Basic InputBox关闭错误