安卓 : what is the standard way to display errors to the user?

标签 android error-handling

我刚刚继承了一个 Android 应用程序。并负责对其进行一些修改。目标设备是 Nexus 7。需要改进的一个方面是错误显示。目前,错误看起来只是作为原始 JSON 文本显示在每个屏幕的底部。

在 Android 中显示错误的首选方式是什么?弹出对话框,还是其他?

谢谢, 弗雷德

最佳答案

第一种方式,Toast 是一个简单快捷的错误通知小部件,但这个小部件具有特殊性,不会附加到调用它们的 Activity。有时,用户没有时间看到错误。此外,当用户退出应用程序时,如果调用 Toast,消息仍会显示,而应用程序不会显示在他的设备上。真的算不上“漂亮”。

另一个可能是Dialog(弹出窗口),这是显示任何错误或重要消息的好方法。该错误确实是可见的,并通过其按钮(确定、取消、..)确认用户已得到充分通知。但是,个人感觉,我觉得这种方式太打扰了..

我建议您使用 Crouton(作者 Benjamin Weiss )来通知用户您的应用程序的错误、信息和消息。您可以在 Useful Android Libraries: Crouton 上找到很好的解释。 .概念是:

[...] to show in-app notifications (not to be confused with Android's persistent notifications) at a fixed place of the Activity to which the notification is relevant. This way the context of the notification is always correct.

这是应用内的通知,类似于 Toast,但始终附加到您的 Activity。您可以在 Google Play 上下载示例这个图书馆在 GitHub .

关于安卓 : what is the standard way to display errors to the user?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22586034/

相关文章:

android - KitKat 中的半透明系统栏和内容边距

php - PHP如何捕获所有错误

google-sheets - 如何避免/绕过/忽略Google表格中的#N/A #NV错误?

cakephp - cakephp 3.8.13处理未经授权的请求,以JSON响应

android - phonegap jquerymobile : how to open external links via Android Browser

android - 在运行 android 应用程序时强制关闭

java - 无法从 sqlite 查询中获取选择列 3

javascript - 错误验证在 AngularJS 中不起作用

r - 相当于 R 中的 "throw"

android - 链接器标志中的非系统库