Flavio Flavio - 1 year ago 136
Android Question

Best practice for displaying error messages

What is the best way of displaying error messages to the user?

Assume the following scenario (just for example, this question relates to common problem, when error may occur in service, in the thread etc.):

  1. We load some data for some screen

  2. Error occurs (Internet is not available, server exception, other exceptions ...)

How to show the error? Possible solutions:

  1. Show toasts - the simplest way but it is not the best (for many errors we'll see many toasts, even if the application works in the background)

  2. Show error somewhere in the screen (e.g. gmail shows 'No connection' at the bottom of the list and proposes to retry)

What is your experience? How do you show user errors? Is there some guides explaining what is the best way?

Answer Source

I have used the alertDialog.. refer the Images. futher google it

For user Attention.

enter image description here

for form Validation edit texts use editText.setError("Your error message") method

for form Validation edit

for internet connection failed

enter image description here

for internent connection failed with retry.

enter image description here

Update 1

For showing some auto terminate info/message we use Toast for example notifying a user that your Email was sent Successfully. We can Use Toast like below

enter image description here

Toast.makeText(context, "Email was sent Successfully.", duration).show()

Note: User can't interact with Default toast, See also Custom Toast Layout

Another option is to use the new Snackbar

enter image description here

Hope this will be helpful

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download