I have fragment in that fragment i am try to call Toast when user enter wrong Login and Password but Toast is not visible when login button is pressed and log above toast is calling but still toast is not visible
Here is my fragment
public class Login_Fragment extends Fragment {
EditText LoginUname,LoginPass;
ImageButton SignIn;
Context context;
public static final String TAG="Login Fragment";
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view= inflater.inflate(R.layout.login_fragment,container,false);
LoginUname= (EditText) view.findViewById(R.id.Login_Box);
LoginPass= (EditText) view.findViewById(R.id.Pass_Box);
SignIn= (ImageButton) view.findViewById(R.id.LoginButton);
SignIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String Phone=LoginUname.getText().toString();
String Password=LoginPass.getText().toString();
new AsyncTask(){
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
Log.d("LOGIN FRAGMENT","Result: "+result); //GETTING RESULT FAIL HERE
if (result.equals("FAIL")){
Log.d("LOGIN FRAGMENT","Result is FAIL"); //THIS LOG SHOWING IN LOGCAT BUT TOAST IS NOT VISIBLE
Toast.makeText(getActivity(), "Invalid Login And Password", Toast.LENGTH_LONG).show();
}
else if (result.equals("SUCCESS")){
Log.d("LOGIN FRAGMENT","Result is Success");
}
}
}.execute();
Log.d("LOGIN FRAGMENT","----LOGIN AND PASSWORD SENT");
}
});
Registration.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Registration_Fragment registrationFragment=new Registration_Fragment();
FragmentManager fragmentManager=getFragmentManager();
FragmentTransaction transaction=fragmentManager.beginTransaction();
transaction.replace(R.id.FragmentLoginRegistration,registrationFragment);
transaction.commit();
}
});
return view;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
this.context=context;
}
}
Log
08-23 14:04:38.115 29053-29053/com.boysjoys.com.pro_working1 D/LOGIN FRAGMENT: Result: FAIL
08-23 14:04:38.115 29053-29053/com.boysjoys.com.pro_working1 D/LOGIN FRAGMENT: Result is FAIL
i have already tried
Toast.makeText(getActivity(), "Invalid Login And Password", Toast.LENGTH_LONG).show();
Toast.makeText(getActivity().getApplicationContext(), "Invalid Login And Password", Toast.LENGTH_LONG).show();
Toast.makeText(Login_Fragment.this.getActivity(), "Invalid Login And Password", Toast.LENGTH_LONG).show();
and almost all method i can use to show toast visible and at last i tried runOnUiThread
but its still not showing.
EDIT 1: Added Log to show that i am getting response from server- "FAIL"
Edit 2: I tried every answer i got but my Toast still not showing up.So is there any chance that my manifest,layout blocks Toast to comes up? if Yes please let me know so i will update my layout,Style,Manifest in my question