Android 'Unable to add window — token null is not for an application' exception

后端 未结 11 2122
名媛妹妹
名媛妹妹 2020-11-28 05:58

I get the following Android exception when I try to open a dialog. Can someone please help me understand what is going on and how can I fix this problem?

and         


        
11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 06:20

    In my case I was trying to create my dialog like this:

    new Dialog(getApplicationContext());
    

    So I had to change for:

    new Dialog(this);
    

    And it works fine for me ;)

提交回复
热议问题