RunOnUiThread () method in fragment
2 answers
Use getActivity()
instead MainActivity.this
. Also use getApplicationContext () method for methodToast.makeText()
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(getActivity().getApplicationContext(),"any mesage",Toast.LENGTH_LONG).show();
}
});
+4
source to share