android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

HA HA HA !!!, You entrapped again in this error. Yes, if you are developing apps for a long time than definitely you faced this issue several times. If your answer is 'NO' than your developing skills are good or may be you didn't face it because you are a fresher. Or if answer is 'YES' than buddy, you forgot something in hurry. you know what is it ?

Error :

android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application.

Solution :

Somewhere in your alert dialog initialization. you passed context of your activity, replace it with [YourActivityName].this . That's it, your app will run perfectly after doing this. If still not working & same error occurs than ask problem in comment with detailed description. We will definitely help you to solve your issue.


  1. private void ShowPopup(){

    final Dialog dialog = new Dialog(mcontext,;
    // nestedScrollView.setBackgroundColor(Color.parseColor("#526565"));
    dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(;
    contactmobile = dialog.findViewById(;
    contactname = dialog.findViewById(;
    ok = dialog.findViewById(;
    // email.setText(mPostData.get(contact.getId()).getEmail());
    // mobile.setText(mPostData.get(contact.getId()).getMobile());
    ok.setOnClickListener(new View.OnClickListener() {
    public void onClick(View view) {
    // Intent intent =new Intent(mcontext,LoginActivity.class);
    // mcontext.startActivity(intent);


  2. is not working this adapter class

  3. Emperor Casino
    Play online casino games at Empire Casino | Try 1xbet for Real Money | No Download and No Registration | No Deposit Required | Join Now! | T&C's Apply! 인카지노 Rating: 3.9 · 제왕카지노 ‎3 votes · ‎Free · ‎Game


Post a Comment