Xamarin.Forms How to: Display Android’s Toast & SnackBar in PCL project

Below is some code to help you to display Toast & SnackBar pop up ONLY in your Xamarin.Forms Android project and calling the pop-up in PCL code.

Prerequisite

We first need to declare a DependencyService interface so we could call this from our PCL project.

Next step would be implement the interface in Android project

Last step would be calling the code in PCL project. We limit the execution to run on Android only by querying the platform in runtime.

End Result

EndResult

Full source code can be found here

Note: If you’re using shared project, I supposed you could just directly call the notification in the code using the compiler directive

#if __ANDROID__
..
#endif