You might consider adding Toast to create your own class that is smart enough to read user preferences before showing the toast.
Then reformat your code to replace Toast with SmartToast.
SmartToast.makeText(this, "message", Toast.LENGTH_SHORT).show();
Add SmartToast.makeText () to return an instance of SmartToast and override show () as follows:
@Override public void show() { if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("showToast", true)) { super.show(); } }
source share