private void showToast(String message)
{
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
}
Should I change to getActivity()
?
private void showToast(String message)
{
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
}
Should I change to getActivity()
?
getApplicationContext()
must be called on an instance of a Context
class, so yes, you should call:
getActivity().getApplicationContext()
You can also just pass getActivity
as the first parameter since the activity itself extends Context
class.