Android dialogs are causing android.view.WindowManager$BadTokenException: Unable to add window

前端 未结 3 1749
青春惊慌失措
青春惊慌失措 2021-01-16 04:48

I have putted my activities in childview and now I cannot display dialogs from my activities and adapters. In my logCat i\'m getting

04-11 12:39:59.823: E/A         


        
3条回答
  •  感情败类
    2021-01-16 04:52

    see here the answer for ActivityGroup.

    For child activity of a ActivityGroup, we cannot be sure that it always exist and live when we use the Context in the child activity such as PrompDialog. For example:

    mPromptDialog = new LoginPromptDialog(this);//this is used as Context
    //But when we use this context it may be destroyed.
    //So this is the parent instance
    mPromptDialog = new LoginPromptDialog(this.getParent());
    

    preference: http://www.cnblogs.com/kaima/archive/2011/08/04/2127813.html

提交回复
热议问题