1. Toast :
It is an Android UI component that is used to show message or notification that does not require any user action. It is independent to the activity in which it is being shown and disappears automatically after the set duration.
2. SnackBar :
It is Android material design UI component. It is used to show popup message to user that requires some user action. It can disappear automatically after set time or can be dismissed by user.
Difference between Toast and SnackBar :
|1.||Toast is Android UI component present since API 1||It was later introduced with material design in API 23|
|2.||It is not linked to an activity.||It is linked with parent activity.|
|3.||User input can’t be taken.||User input can be taken.|
|4.||It can’t be shown indefinitely||It can be shown for indefinite duration|
|5.||It can’t be closed by user action||It can be closed by user action.|
|6.||It is mostly used to show feedback message||It is used show message that need user action|
|7.||It is used for showing info messages to user||It is used for showing warning/info type messages to user that needs attention.|
|8.||It can’t be closed by swiping.||It can be closed by swipe.|