I have created an xamarin android app incorporating toast popups that display when users lose, then regain internet connection in my app.
These toasts appear correctly but when I my app is in the background i still get the toasts displaying when i lose/regain internet connection displaying even over other apps that are in the foreground.
I have tried to use a global instance of the toast class then call toast.cancel() on onstop and onpause events, code below. Any ideas?
//my global toast class
Toast toast;
//create a toast message and display
if (toast != null) { toast.Cancel(); }
toast = Toast.MakeText(Application.Context, "You are Offline.", ToastLength.Long).show();
protected override void OnStop()
{
base.OnStop();
if (toast != null) toast.Cancel();
}
protected override void OnPause()
{
base.OnPause();
if (toast != null) toast.Cancel();
}